June 21, 2013
PHP ['SCRIPT_NAME'] returning empty string
I was working with Slim (v2.2.x) the other day and saw that a PHP warning was being thrown in one of the interal Slim files:
Warning: strpos(): Empty needle in /vendor/slim/slim/Slim/Environment.php on line 143 The code throwing the warning was the following if statement:
if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) { The actual issue was that $_SERVER['SCRIPT_NAME'] was an empty string, so strpos was complaining as that is invalid syntax.
...
Read more