<?php
class a {
public $t = 3;
public function call($fun) {
$b = $fun($p);
}
}
class b {
public $t = 5;
public function test() {
$p = 2;
a::call(function()use($p){echo $this->t;});
}
}
$b = new b();
$b->test();
Fatal error: Uncaught Error: Non-static method a::call() cannot be called statically in /in/6aCkZ:13
Stack trace:
#0 /in/6aCkZ(17): b->test()
#1 {main}
thrown in /in/6aCkZ on line 13
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 a::call() cannot be called statically in /in/6aCkZ:13
Stack trace:
#0 /in/6aCkZ(17): b->test()
#1 {main}
thrown in /in/6aCkZ on line 13
Process exited with code 255.
Deprecated: Non-static method a::call() should not be called statically in /in/6aCkZ on line 13
Notice: Undefined variable: p in /in/6aCkZ on line 6
5
Output for 7.3.32 - 7.3.33
5
Output for 5.6.8 - 5.6.28
Deprecated: Non-static method a::call() should not be called statically, assuming $this from incompatible context in /in/6aCkZ on line 13
Notice: Undefined variable: p in /in/6aCkZ on line 6
5
Output for 5.5.24 - 5.5.35
Strict Standards: Non-static method a::call() should not be called statically, assuming $this from incompatible context in /in/6aCkZ on line 13
Notice: Undefined variable: p in /in/6aCkZ on line 6
5