cvs: phpdoc /en/reference/funchand/functions call-user-func-array.xml call-user-func.xml /en/reference/spl/functions spl-autoload-register.xml

From: Date: Wed, 23 Jan 2008 19:06:10 +0000
Subject: cvs: phpdoc /en/reference/funchand/functions call-user-func-array.xml call-user-func.xml /en/reference/spl/functions spl-autoload-register.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1060@lists.php.net to get a copy of this message
felipe Wed Jan 23 19:06:10 2008 UTC Modified files: /phpdoc/en/reference/funchand/functions call-user-func.xml call-user-func-array.xml /phpdoc/en/reference/spl/functions spl-autoload-register.xml Log: Add example related to namespace http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/funchand/functions/call-user-func.xml?r1=1.17&r2=1.18&diff_format=u Index: phpdoc/en/reference/funchand/functions/call-user-func.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func.xml:1.17 phpdoc/en/reference/funchand/functions/call-user-func.xml:1.18 --- phpdoc/en/reference/funchand/functions/call-user-func.xml:1.17 Wed Jun 20 22:24:30 2007 +++ phpdoc/en/reference/funchand/functions/call-user-func.xml Wed Jan 23 19:06:10 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.17 $ --> +<!-- $Revision: 1.18 $ --> <refentry xml:id="function.call-user-func" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>call_user_func</refname> @@ -97,6 +97,29 @@ </programlisting> </example> <example> + <title><function>call_user_func</function> using namespace name</title> + <programlisting role="php"> +<![CDATA[ +<?php + +namespace Foobar; + +class Foo { + static public function test() { + print "Hello world!\n"; + } +} + +call_user_func(__NAMESPACE__ .'::Foo::test'); // As of PHP 5.3.0 +// Hello world! +call_user_func(array(__NAMESPACE__ .'::Foo', 'test')); // As of PHP 5.3.0 +// Hello world! + +?> +]]> + </programlisting> + </example> + <example> <title>Using a class method</title> <programlisting role="php"> <![CDATA[ http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/funchand/functions/call-user-func-array.xml?r1=1.18&r2=1.19&diff_format=u Index: phpdoc/en/reference/funchand/functions/call-user-func-array.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.18 phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.19 --- phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.18 Wed Nov 21 14:42:45 2007 +++ phpdoc/en/reference/funchand/functions/call-user-func-array.xml Wed Jan 23 19:06:10 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <refentry xml:id="function.call-user-func-array" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>call_user_func_array</refname> @@ -79,6 +79,32 @@ ]]> </programlisting> </example> + <example> + <title><function>call_user_func_array</function> using namespace name</title> + <programlisting role="php"> +<![CDATA[ +<?php + +namespace Foobar; + +class Foo { + static public function test($name) { + print "Hello {$name}!\n"; + } +} + +// As of PHP 5.3.0 +call_user_func_array(__NAMESPACE__ .'::Foo::test', array('Hannes')); +// Hello Hannes! + +// As of PHP 5.3.0 +call_user_func_array(array(__NAMESPACE__ .'::Foo', 'test'), array('Philip')); +// Hello Philip! + +?> +]]> + </programlisting> + </example> </para> </refsect1> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/functions/spl-autoload-register.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/spl/functions/spl-autoload-register.xml diff -u phpdoc/en/reference/spl/functions/spl-autoload-register.xml:1.7 phpdoc/en/reference/spl/functions/spl-autoload-register.xml:1.8 --- phpdoc/en/reference/spl/functions/spl-autoload-register.xml:1.7 Mon Dec 24 12:30:23 2007 +++ phpdoc/en/reference/spl/functions/spl-autoload-register.xml Wed Jan 23 19:06:10 2008 @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.spl-autoload-register" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>spl_autoload_register</refname> @@ -25,6 +25,41 @@ the __autoload function by either spl_autoload() or spl_autoload_call(). </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>spl_autoload_register</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +namespace Foobar; + +class Foo { + static public function test($name) { + print '[['. $name .']]'; + } +} + +spl_autoload_register(__NAMESPACE__ .'::Foo::test'); // As of PHP 5.3.0 + +new InexistentClass; + +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +[[Foobar::InexistentClass]] +Fatal error: Class 'Foobar::InexistentClass' not found in ... +]]> + </screen> + </example> + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file

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