New question

Question:

Date: 04-02-2025 06:19:52 (In Spanish)

[Aporte] DEPRECATED [8192] strlen(): Passing null to parameter #1 ($string) of type string is deprecated[Resolved]

Para los que están recibiendo este error:
DEPRECATED [8192] strlen(): Passing null to parameter #1 ($string) of type string is deprecated

la función strlen en PHP 8.2 arroja un Deprecated cuando se le pasa un null, para poder permitir null y no tener que modificar en gran medida tu código puedes armar tu propia función que si soporte null (un wrapper de la función original).

Idea con una clase MyHelper:
class MyHelper {

    public static function strlen(?string $texto): int {
        return strlen($texto ?? "");
    }

}

Función 			Reemplazo Recomendado
strlen(	MyHelper::strlen(



Para este ejemplo con la clase MyHelper, directamente hace un Ctrl + H en su editor (remplazar) y remplazar por ejemplo "strlen(" por "MyHelper::strlen(", y no es necesario intervenir en cada archivo, se hace por remplace.

Saludos y buen código!
Tags: Deprecated features - Input - PHP Votes: 1 - Answers: 0 - Views: 2 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

No replies for this question, be the first to answer.
To actively participate in the community first must authenticate, enter the system.Sign In
 
frjcbbae garagebible.com