2

Since which version of PHP is it possible to use the following:

$class::method()->something($val);

I need to use this but in 5.2.11 I get a T_PAMAAYIM_whatever error, and I just wanted to determine whether it's version related or bad coding.

If it's version related, what's a valid alternative?

Thank you.

3 Answers 3

5

I think it's a PHP 5.3 feature. You should be able to call_user_func(array($class, $method), $val); in "any" version.

Sign up to request clarification or add additional context in comments.

Comments

0

This is indeed a PHP5.3 feature. For now use call_user_func(array('Class', 'method'), $arg), and in the future PHP5.4 will even make it possible to do:

$callback = array('Class', 'method');
$callback($arg);

Comments

0

Added in PHP 5.3. From the release notes:

New features

  • Dynamic access to static methods is now possible.

http://php.net/manual/en/migration53.new-features.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.