added & to object callback example, changed example to be more verbose and easier to follow

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@132563 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Davey Shafik 2003-06-19 22:29:12 +00:00
parent e733cc6183
commit 22a94eefc4

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.119 $ -->
<!-- $Revision: 1.120 $ -->
<chapter id="language.types">
<title>Types</title>
@ -2244,24 +2244,24 @@ $var = NULL;
<?php
// simple callback example
function foobar() {
echo "hello world!";
function my_callback_function() {
echo 'hello world!';
}
call_user_func("foobar");
call_user_func('my_callback_function');
// method callback examples
class foo {
function bar() {
echo "hello world!";
}
class my_class {
function my_callback_method() {
echo 'hello world!';
}
}
// static class method call without instantiating an object
call_user_func(array("foo", "bar"));
call_user_func(array('my_class', 'my_callback_method'));
$foo = new foo;
$obj = new my_class;
call_user_func(array($foo, "bar")); // object method call
call_user_func(array(&$obj, 'my_callback_method')); // object method call
?>