Doc #64907 [Opn]: classname regex seems invalid

From: Date: Thu, 23 May 2013 07:58:34 +0000
Subject: Doc #64907 [Opn]: classname regex seems invalid
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9872@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64907&edit=1 ID: 64907 Updated by: salathe@php.net Reported by: php at kingsquare dot nl Summary: classname regex seems invalid Status: Open Type: Documentation Problem Package: Documentation problem Operating System: n/a PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Your testing regular expression is not anchored to the end of the subject string. It is matching *only* the letter "a". Try again with a $ anchor. Previous Comments: ------------------------------------------------------------------------ [2013-05-23 06:40:50] php at kingsquare dot nl Description: ------------ I've tried to use the given regex for testing of my classname (which is dynamically built from various sources) but it seems that the given regex allows characters which shouldnt be allowed. The page http://php.net/manual/en/language.oop5.basic.php gives the '^[a-zA- Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' regex. But this would allow not only strange characters like '»×' which might be intened but also 'a:' which ofcourse would fail from a parse error... Test script: --------------- <?php $controllerName = 'a:'; var_dump(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $controllerName)); eval('class '.$controllerName.' {}'); exit; Expected result: ---------------- I'd expect the parse error, but also the not the valid pregmatch. thus: int 0 ( ! ) Parse error: syntax error, unexpected ':', expecting '{' in test.php(5) : eval()'d code on line 1 Actual result: -------------- int 1 ( ! ) Parse error: syntax error, unexpected ':', expecting '{' in test.php(5) : eval()'d code on line 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64907&edit=1

« previous php.doc.bugs (#9872) next »