Made the callback examples better. Should we create an entity for functions which are not really functions, or an faq entry, or put them in a separate list on reserved keywords?

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@170102 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-10-09 05:35:29 +00:00
parent b75802bd35
commit 18557a4d79

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.142 $ -->
<!-- $Revision: 1.143 $ -->
<chapter id="language.types">
<title>Types</title>
@ -2305,24 +2305,25 @@ $var = NULL;
<programlisting role="php">
<![CDATA[
<?php
// simple callback example
// An example callback function
function my_callback_function() {
echo 'hello world!';
}
call_user_func('my_callback_function');
// method callback examples
// An example callback method
class MyClass {
function myCallbackMethod() {
echo 'Hello World!';
}
}
// static class method call without instantiating an object
// Type 1: Simple callback
call_user_func('my_callback_function');
// Type 2: Static class method call
call_user_func(array('MyClass', 'myCallbackMethod'));
// object method call
// Type 3: Object method call
$obj = new MyClass();
call_user_func(array(&$obj, 'myCallbackMethod'));
?>