24th April 2020, 12:48 PM
I was helping a friend with some PHP. It was working fine on my computer but failing with no errors on his. I told him to add the debugging code listed below to show the errors:
Upon adding, his machine threw this error:
Catchable fatal error: Argument 1 passed to myFunction() must be an instance of string, string given, called in /file.php on line 88 and defined in /file.php on line 49
So basically, PHP was requiring a string... but throwing an error when a string was passed. Nice job PHP.
Advice: always sync your PHP versions across dev environments! This was due in part to specifying a type declaration in an older version of PHP than I was using.
PHP Code:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL | E_STRICT);
Upon adding, his machine threw this error:
Catchable fatal error: Argument 1 passed to myFunction() must be an instance of string, string given, called in /file.php on line 88 and defined in /file.php on line 49
So basically, PHP was requiring a string... but throwing an error when a string was passed. Nice job PHP.
Advice: always sync your PHP versions across dev environments! This was due in part to specifying a type declaration in an older version of PHP than I was using.