mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
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:
parent
e733cc6183
commit
22a94eefc4
1 changed files with 11 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue