Prefer anonymous function over create_function()

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330241 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2013-05-16 18:25:02 +00:00
parent f68abbe82c
commit fcf6390340

View file

@ -66,7 +66,7 @@
<para>
<example>
<title><function>preg_replace_callback</function> and
<function>create_function</function></title>
anonymous function</title>
<programlisting role="php">
<![CDATA[
<?php
@ -77,12 +77,9 @@ while (!feof($fp)) {
$line = fgets($fp);
$line = preg_replace_callback(
'|<p>\s*\w|',
create_function(
// single quotes are essential here,
// or alternative escape all $ as \$
'$matches',
'return strtolower($matches[0]);'
),
function ($matches) {
return strtolower($matches[0]);
},
$line
);
echo $line;