When I use call_user_func on a non-static method in PHP 5.2 I get a Strict Warning:
Strict Standards: Non-static method User::register() cannot be called statically
But on PHP 5.3.1 I don’t get this warning. Is this a bug in PHP 5.3.1 or is the warning removed?
It is perfectly OK — but note that you have to pass an object that’s an instance of your class, to indicate on which object the non-static method shall be called :
You should not use something like this :
Which will give you the following warning :
(This would work perfectly fine if the method was declared as static… but it’s not, here)
For more informations, you can take a look at the [**callback**][1] section of the manual, which states, amongst other things *(quoting)* :
If you get a strict error with an old version of PHP (e.g. 5.2), it’s probably a matter of configuration — I’m thinking about the [**`error_reporting`**][2] directive.
Note that
E_ALLincludesE_STRICTfrom PHP 5.4.0 (quoting) :