Doc #67263 [Opn->Nab]: Regex incorrect in User-defined functions doc'n
| From: | levim@php.net | Date: | Tue, 13 May 2014 15:27:17 +0000 |
| Subject: | Doc #67263 [Opn->Nab]: Regex incorrect in User-defined functions doc'n | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11210@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67263&edit=1
ID: 67263
Updated by: levim@php.net
Reported by: lewis dot berman at verizon dot net
Summary: Regex incorrect in User-defined functions doc'n
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows 7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The regular expression is defining the identity of the function name, not all of the requirements
around it. Additionally, in actual code a user-defined function is guaranteed to not be at the start
of the string; it will always have
function [&] come before it.
The documentation could perhaps be improved but it's not a bug.
Previous Comments:
------------------------------------------------------------------------
[2014-05-13 03:49:02] lewis dot berman at verizon dot net
Description:
------------
---
From manual page: http://www.php.net/functions.user-defined
---
Regex in the following text requires a leading caret ("^"):
"A valid function name starts with a letter or underscore, followed by any number of letters,
numbers, or underscores. As a regular expression, it would be expressed thus:
[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*."
I.e., the regex should be ^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.
Otherwise the subject string '014A7' will match, and that is not in accordance with the
text. The script was run under Bitnami wampstack-5.4.28-0.
Test script:
---------------
<?php
$match_result = preg_match("/[a-zA-Z][a-zA-Z0-9]*./", '014A7');
echo $match_result;
$match_result = preg_match("/^[a-zA-Z][a-zA-Z0-9]*./", '014A7');
echo $match_result;
?>
Actual result:
--------------
The script returns 0 for the first match, 1 for the second.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67263&edit=1