eregi returns... *what* exactly?
Posted: Thu Oct 12, 2006 2:52 am
Hi,
According to the PHP manual, the function eregi:
"Returns the length of the matched string if a match for pattern was found in string"
The following code..
will echo
If so, then why does introducing illegal characters in to $thing..
Return nothing at all? According to the first example, the 'match' was only one character long. The illegal characters do not appear until after position 1 in $thing.
Is there a typo in the PHP manual? Should it instead read "Returns the number of matched patterns found in string".
If the first example of my code returned the length of the entire string, that would make sense. But it didn't.
So what's going on?
Thanks.
According to the PHP manual, the function eregi:
"Returns the length of the matched string if a match for pattern was found in string"
The following code..
Code: Select all
$thing = 'happybirthdaytoyou';
$result = (eregi ('^[[]\.\' \-]{2,30}$', $thing));
echo $result;to the browser. Does this mean it is only matching the first character in $thing?1
If so, then why does introducing illegal characters in to $thing..
Code: Select all
$thing = 'happy&&birthdaytoyou';
$result = (eregi ('^[[]\.\' \-]{2,30}$', $thing));
echo $result;Is there a typo in the PHP manual? Should it instead read "Returns the number of matched patterns found in string".
If the first example of my code returned the length of the entire string, that would make sense. But it didn't.
So what's going on?
Thanks.