fork download
  1. <?php
  2. $code = <<<EOS
  3. namespace monkeypatch;
  4.  
  5. \$s = "moofoo";
  6.  
  7. echo "This should six, but is it?: " . strlen(\$s) . PHP_EOL;
  8. echo "Whoa! And now it is six, right?: " . \strlen(\$s) . PHP_EOL;
  9.  
  10. function strlen(\$x)
  11. {
  12.   return -3.14;
  13. }
  14. EOS;
  15.  
  16. eval($code);
  17.  
  18. echo "While out of namespaces it is still six...: " . strlen("moofoo") . PHP_EOL;
Success #stdin #stdout 0s 13112KB
stdin
Standard input is empty
stdout
Parse error: syntax error, unexpected T_STRING in /home/eBMLzC/prog.php(16) : eval()'d code on line 1
While out of namespaces it is still six...: 6