Welcome Guest, Not a member yet? Register   Sign In
Uncaught ErrorException: strtolower()
#6

(This post was last modified: 11-08-2021, 04:59 PM by John_Betong.)

The declaration should be at the very beginning of the file and if not the an error will be displayed. Give it a try and notice the error message.

Unlike error_reporting(); and ini_set(‘variable’, ‘parameter’); apply to all code following the statements including include files. Strict_types **ONLY** applies to the containing file. This is cunning and essential to ensure legacy included scripts are not affected.

Unfortunately using strict_types in your file will not solve the error because the valid_ip(…); function should only accept strings and NULL is not a string. The function incorrectly accepts NULL as a string and should be replaced with an empty string.

FormatRules.php file should be rewritten forcing strict_types and the function also rewritten to only accept strings.

When using strict_types on your own files, notice since PHP 7.0 all PHP native functions now throw errors when incompatible parameters are passed. Try ini_set(‘display_errors’, true); and notice the errors.

Unfortunately the powers to be prefer using PHP Unit Testing which fails to highlight these strict_type incompatibilities. PHP Unit Testing still passes orange parameters when only apples are valid Smile

I wholeheartedly agree with PHP’s decision to comply to strict_types because once adopted, obscure errors are drastically reduced. Initially numerous errors require small changes for successful validation but results in having more robust code… which will not fail in future PHP versions.

I sincerely wish the developer team would try using strict_types and correct errors which PHP Unit Testing misses. Perhaps strict_types would eliminate the necessity for PHP Unit Testing.

Trust in PHP instead of Third Party applications… because PHP has been refining their code since “June 8, 1995; 26 years ago” Smile
Reply


Messages In This Thread
RE: Uncaught ErrorException: strtolower() - by John_Betong - 11-08-2021, 04:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB