svn: /phpdoc/en/trunk/reference/funchand/functions/ call-user-func-array.xml

From: Date: Fri, 11 Sep 2009 11:03:03 +0000
Subject: svn: /phpdoc/en/trunk/reference/funchand/functions/ call-user-func-array.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4905@lists.php.net to get a copy of this message
bjori Fri, 11 Sep 2009 11:03:03 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288261 Log: - Removed weird example with missing example output - Add an example how to call normal function, and a method Changed paths: U phpdoc/en/trunk/reference/funchand/functions/call-user-func-array.xml Modified: phpdoc/en/trunk/reference/funchand/functions/call-user-func-array.xml =================================================================== --- phpdoc/en/trunk/reference/funchand/functions/call-user-func-array.xml 2009-09-11 08:22:19 UTC (rev 288260) +++ phpdoc/en/trunk/reference/funchand/functions/call-user-func-array.xml 2009-09-11 11:03:03 UTC (rev 288261) @@ -58,29 +58,30 @@ <programlisting role="php"> <![CDATA[ <?php -function debug($var, $val) -{ - echo "***DEBUGGING\nVARIABLE: $var\nVALUE:"; - if (is_array($val) || is_object($val) || is_resource($val)) { - print_r($val); - } else { - echo "\n$val\n"; +function foobar($arg, $arg2) { + echo __FUNCTION__, " got $arg and $arg2\n"; +} +class foo { + function bar($arg, $arg2) { + echo __METHOD__, " got $arg and $arg2\n"; } - echo "***\n"; } -$c = new StdClass(); -$host = $_SERVER["PHP_SELF"]; -call_user_func_array('debug', array("host", $host)); -call_user_func_array('debug', array("c", $c)); -call_user_func_array('debug', array("_POST", $_POST)); +// Call the foobar() function with 2 arguments +call_user_func_array("foobar", array("one", "two")); + +// Call the $foo->bar() method with 2 arguments +$foo = new foo; +call_user_func_array(array($foo, "bar"), array("three", "four")); ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[ +foobar got one and two +foo::bar got three and four ]]> </screen> </example>

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