Remove mentions of create_function from docs. Add caution to create_function docs advising to use anon funcs instead.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@331556 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Nikita Popov 2013-09-28 15:43:16 +00:00
parent 254b04328c
commit a0efd60818
7 changed files with 20 additions and 16 deletions

View file

@ -44,10 +44,9 @@
</para>
<para>
Apart from common user-defined function, <function>create_function</function>
can also be used to create an anonymous callback function. As of PHP 5.3.0
it is possible to also pass a
<link linkend="functions.anonymous">closure</link> to a callback parameter.
Apart from common user-defined function,
<link linkend="functions.anonymous">anonymous functions</link> can also be
passed to a callback parameter.
</para>
<para>

View file

@ -346,7 +346,6 @@ array(1) {
<member><function>array_filter</function></member>
<member><function>array_reduce</function></member>
<member><function>array_walk</function></member>
<member><function>create_function</function></member>
<member>&seealso.callback;</member>
</simplelist>
</para>

View file

@ -152,7 +152,6 @@ c. fruit: apple
<simplelist>
<member><function>array_walk_recursive</function></member>
<member><function>iterator_apply</function></member>
<member><function>create_function</function></member>
<member><function>list</function></member>
<member><function>each</function></member>
<member><function>call_user_func_array</function></member>

View file

@ -17,6 +17,17 @@
Creates an anonymous function from the parameters passed, and
returns a unique name for it.
</para>
<caution>
<para>
This function internally performs an <function>eval</function> and as such has the
same security issues as <function>eval</function>. Additionally it has bad performance
and memory usage characteristics.
</para>
<para>
If you are using PHP 5.3.0 or newer a native
<link linkend="functions.anonymous">anonymous function</link> should be used instead.
</para>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;

View file

@ -56,9 +56,8 @@
You'll often need the <parameter>callback</parameter> function
for a <function>mb_ereg_replace_callback</function> in just one place.
In this case you can use an
<link linkend="functions.anonymous">anonymous function</link> (since
PHP 5.3.0) or <function>create_function</function> to
declare an anonymous function as callback within the call to
<link linkend="functions.anonymous">anonymous function</link> to
declare the callback within the call to
<function>mb_ereg_replace_callback</function>. By doing it this way
you have all information for the call in one place and do not
clutter the function namespace with a callback function's name
@ -175,7 +174,6 @@ echo mb_ereg_replace_callback(
<simplelist>
<member><function>mb_regex_encoding</function></member>
<member><function>mb_ereg_replace</function></member>
<member><function>create_function</function></member>
<member><link linkend="functions.anonymous">Anonymous functions</link></member>
<member>&seealso.callback;</member>
</simplelist>

View file

@ -45,7 +45,7 @@ print_r(ob_list_handlers());
ob_end_flush();
// anonymous functions
ob_start(create_function('$string', 'return $string;'));
ob_start(function($string) { return $string; });
print_r(ob_list_handlers());
ob_end_flush();
?>
@ -66,7 +66,7 @@ Array
Array
(
[0] => default output handler
[0] => Closure::__invoke
)
]]>
</screen>

View file

@ -55,9 +55,8 @@
You'll often need the <parameter>callback</parameter> function
for a <function>preg_replace_callback</function> in just one place.
In this case you can use an
<link linkend="functions.anonymous">anonymous function</link> (since
PHP 5.3.0) or <function>create_function</function> to
declare an anonymous function as callback within the call to
<link linkend="functions.anonymous">anonymous function</link> to
declare the callback within the call to
<function>preg_replace_callback</function>. By doing it this way
you have all information for the call in one place and do not
clutter the function namespace with a callback function's name
@ -235,7 +234,6 @@ echo $output;
<member><link linkend="pcre.pattern">PCRE Patterns</link></member>
<member><function>preg_replace</function></member>
<member><function>preg_last_error</function></member>
<member><function>create_function</function></member>
<member><link linkend="functions.anonymous">Anonymous functions</link></member>
<member>&seealso.callback;</member>
</simplelist>