|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-12-31 02:19 UTC] jzumbrun at gmail dot com
Description:
------------
// $line equals line below from file:
$route['infox/(.*)'] = "articles/$1";
Basically I have to manually put an \ in front of the / char after infox. preg_quote() wont escape it and the documentation doesnt say i need to escape / chars. preg_match() is forcing me to put one there.
Reproduce code:
---------------
---
From manual page: function.preg-quote
---
$urlClass = '\$route\['infox'/\(\.\*\)'\]';
preg_match("/$urlClass/", $line);
Expected result:
----------------
no errors
Actual result:
--------------
Message: preg_match() [function.preg-match]: Unknown modifier '\'
if i use $urlClass = '\$route\['infox'\/\(\.\*\)'\]';
it works (notice the \ infront of the 3rd char after infox)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
The manual doesn't specifically talk about / because the regex separator character is completely configurable. If you use another char, like ~ for example, then you don't have to escape the / eg. preg_match("~$urlClass~", $line);