svn: /phpdoc/en/trunk/language/ functions.xml

From: Date: Tue, 28 Jul 2015 19:23:16 +0000
Subject: svn: /phpdoc/en/trunk/language/ functions.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13490@lists.php.net to get a copy of this message
cmb Tue, 28 Jul 2015 19:23:16 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=337259 Log: updated variable function documentation (fixes #70160) Bug: https://bugs.php.net/70160 (Verified) string with double colon is callable, but cannot be called Changed paths: U phpdoc/en/trunk/language/functions.xml Modified: phpdoc/en/trunk/language/functions.xml =================================================================== --- phpdoc/en/trunk/language/functions.xml 2015-07-28 17:22:49 UTC (rev 337258) +++ phpdoc/en/trunk/language/functions.xml 2015-07-28 19:23:16 UTC (rev 337259) @@ -1089,12 +1089,70 @@ </programlisting> </example> </para> + <para> + As of PHP 5.4.0, you can call any <type>callable</type> stored in a variable. + <example> + <title>Complex callables</title> + <programlisting role="php"> +<![CDATA[ +class Foo +{ + static function bar() + { + echo "bar\n"; + } + function baz() + { + echo "baz\n"; + } +} + +$func = array("Foo", "bar"); +$func(); // prints "bar" +$f = array(new Foo, "baz"); +$func(); // prints "baz" +$f = "Foo::bar"; +$func(); // prints "bar" as of PHP 7.0.0; prior, it raised a fatal error +]]> + </programlisting> + </example> + </para> <para> See also <function>is_callable</function>, <function>call_user_func</function>, <link linkend="language.variables.variable"> variable variables</link> and <function>function_exists</function>. </para> + + <sect2 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>7.0.0</entry> + <entry> + 'ClassName::methodName' is allowed as variable function. + </entry> + </row> + <row> + <entry>5.4.0</entry> + <entry> + Arrays, which are valid callables, are allowed as variable functions. + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </sect2> </sect1> <sect1 xml:id="functions.internal">

« previous php.doc.cvs (#13490) next »