#38350 [NEW]: regexpr string causes error at runtime.

From: Date: Sat, 05 Aug 2006 18:09:16 +0000
Subject: #38350 [NEW]: regexpr string causes error at runtime.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100401@lists.php.net to get a copy of this message
From: syacko at nayaco dot com Operating system: RHEL 4 update 3 Linux PHP version: 5.1.4 PHP Bug Type: Scripting Engine problem Bug description: regexpr string causes error at runtime. 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 -- Edit bug report at http://bugs.php.net/?id=38350&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38350&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38350&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38350&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38350&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38350&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38350&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38350&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38350&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38350&r=support Expected behavior: http://bugs.php.net/fix.php?id=38350&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38350&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38350&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38350&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38350&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38350&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38350&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38350&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38350&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38350&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38350&r=mysqlcfg

« previous php.bugs (#100401) next »