<?php
class CFoo {
public function foo() {
$this->foo = 'foo';
}
}
class CBar {
public function bar() {
CFoo::foo();
}
}
$cBar = new CBar();
$cBar->bar();
echo $cBar->foo;
Fatal error: Uncaught Error: Non-static method CFoo::foo() cannot be called statically in /in/i11b9:11
Stack trace:
#0 /in/i11b9(16): CBar->bar()
#1 {main}
thrown in /in/i11b9 on line 11
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
Fatal error: Uncaught Error: Non-static method CFoo::foo() cannot be called statically in /in/i11b9:11
Stack trace:
#0 /in/i11b9(16): CBar->bar()
#1 {main}
thrown in /in/i11b9 on line 11
Process exited with code 255.
Deprecated: Non-static method CFoo::foo() should not be called statically in /in/i11b9 on line 11
Fatal error: Uncaught Error: Using $this when not in object context in /in/i11b9:5
Stack trace:
#0 /in/i11b9(11): CFoo::foo()
#1 /in/i11b9(16): CBar->bar()
#2 {main}
thrown in /in/i11b9 on line 5
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Using $this when not in object context in /in/i11b9:5
Stack trace:
#0 /in/i11b9(11): CFoo::foo()
#1 /in/i11b9(16): CBar->bar()
#2 {main}
thrown in /in/i11b9 on line 5
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Deprecated: Non-static method CFoo::foo() should not be called statically, assuming $this from incompatible context in /in/i11b9 on line 11
foo