<?php
// Call a static method on a string class or object returned by
// an instance method call
$foo->bar()::baz();
class bla {
static function bar(){
static $flag = 1;
$flag++;
if ($flag == 2 ) {
return 'blee';
}
if ($flag == 3){
return new blee;
}
}
}
class blee {
static function baz() {
echo "Oh, for the baz of it!\n";
}
}
/**********************************/
$foo = new bla;
echo $foo::bar()::baz();
Warning: Undefined variable $foo in /in/EcGZn on line 4
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/EcGZn:4
Stack trace:
#0 {main}
thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Undefined variable $foo in /in/EcGZn on line 4
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/EcGZn:4
Stack trace:
#0 {main}
thrown in /in/EcGZn on line 4
Process exited with code 255.
Notice: Undefined variable: foo in /in/EcGZn on line 4
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/EcGZn:4
Stack trace:
#0 {main}
thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/EcGZn:4
Stack trace:
#0 {main}
thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: foo in /in/EcGZn on line 4
Fatal error: Uncaught Error: Call to a member function bar() on unknown in /in/EcGZn:4
Stack trace:
#0 {main}
thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /in/EcGZn on line 4
Process exited with code 255.