Doc #68632 [Opn->Csd]: Bad practice preg_quote() example
| From: | aharvey@php.net | Date: | Fri, 19 Dec 2014 23:23:31 +0000 |
| Subject: | Doc #68632 [Opn->Csd]: Bad practice preg_quote() example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11743@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68632&edit=1
ID: 68632
Updated by: aharvey@php.net
Reported by: mfischer@php.net
Summary: Bad practice preg_quote() example
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Great catch!
Previous Comments:
------------------------------------------------------------------------
[2014-12-19 23:23:26] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=335316
Log: Include delimiter in preg_quote() example.
Fixes doc bug #68632 (Bad practice preg_quote() example).
------------------------------------------------------------------------
[2014-12-19 23:15:37] mfischer@php.net
Description:
------------
http://php.net/manual/en/function.preg-quote.php
The preg_quote() example is a bad practice:
$textbody = "This book is *very* difficult to find.";
$word = "*very*";
$textbody = preg_replace ("/" . preg_quote($word) . "/",
"<i>" . $word . "</i>",
$textbody);
If the text would contain a '/' this would easily break and thus the example should
include the delimiter, i.e.
preg_quote($word, "/")
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68632&edit=1