mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
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:
parent
f68abbe82c
commit
fcf6390340
1 changed files with 4 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue