|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-05 18:19 UTC] tony2001@php.net
[2006-08-05 18:25 UTC] syacko at nayaco dot com
[2006-08-05 18:27 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 03:00:02 2026 UTC |
Description: ------------ In a class, using a private variable with a regular expression will cause a parseing error. The same regular expression in a method variable will not. Error Message: Parse error: syntax error, unexpected '"' in /nayaco/apps/releasemanager/test.php on line 8 Reproduce code: --------------- Code that does not work: <?php $x = new regClass(); $x->main(); $x = null; exit; class regClass { private $myFilter = "/^NC([a-zA-Z]+)\.php$/"; public function main() { echo $this->myFilter."\n"; echo preg_match($this->myFilter, "NCScott.php", $myMatches); print_r($myMatches); } } ?> Code that works: <?php $x = new regClass(); $x->main(); $x = null; exit; class regClass { public function main() { $myFilter = "/^NC([a-zA-Z]+)\.php$/"; echo $myFilter."\n"; echo preg_match($myFilter, "NCScott.php", $myMatches); print_r($myMatches); } } ?> Expected result: ---------------- Both sets of code should produce the same result: /^NC([a-zA-Z]+)\.php$/ 1Array ( [0] => NCScott.php [1] => Scott ) Actual result: -------------- Parse error: syntax error, unexpected '"' in /nayaco/apps/releasemanager/test.php on line 8