cvs: /phpdoc/functions pcre.sgml

From: Date: Sat, 17 Jul 1999 16:57:59 +0000
Subject: cvs: /phpdoc/functions pcre.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-8659@lists.php.net to get a copy of this message
andrey Sat Jul 17 16:57:59 1999 EDT Modified files: /phpdoc/functions pcre.sgml Log: Docs on /e option. Index: phpdoc/functions/pcre.sgml diff -u phpdoc/functions/pcre.sgml:1.4 phpdoc/functions/pcre.sgml:1.5 --- phpdoc/functions/pcre.sgml:1.4 Sat Jul 17 15:42:51 1999 +++ phpdoc/functions/pcre.sgml Sat Jul 17 16:57:59 1999 @@ -247,6 +247,18 @@ though. <para> + <screen>/e</screen> option makes + <function>preg_replace</function> treat the + <parameter>replacement</parameter> parameter as PHP code after + the appropriate references substitution is done. Tip: make sure + that <parameter>replacement</parameter> constitutes a valid PHP + code string, otherwise PHP will complain about a parse error at + the line containing <function>preg_replace</function>. + <note> + This option was added in PHP 4.0. + </note> + + <para> <example> <title>Replacing several values</title> <programlisting> @@ -262,6 +274,17 @@ $startDate = 5/27/1999 </programlisting> + <example> + <title>Using /e option</title> + <programlisting> +preg_replace("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); + </programlisting> + + <para> + This would capitalize all HTML tags in the input text. + </example> + + <para> See also <function>preg_match</function>, <function>preg_match_all</function>, and <function>preg_split</function>. @@ -442,6 +465,20 @@ within special character sequences in a pattern, for example within the sequence (?( which introduces a conditional subpattern. + </listitem> + </varlistentry> + + <varlistentry> + <term><emphasis>e</emphasis></term> + <listitem> + <simpara> + If this option is set, <function>preg_replace</function> + does normal substitution of \\ references in the + replacement string, evaluates it as PHP code, and uses the + result for replacing the search string. + + <simpara> + Only <function>preg_replace</function> uses this option, it is ignored by other PCRE functions. </listitem> </varlistentry>

« previous php.dev (#8659) next »