#29712 [Opn->Csd]: ereg() does not return TRUE
| From: | vrana@php.net | Date: | Fri, 10 Sep 2004 14:37:27 +0000 |
| Subject: | #29712 [Opn->Csd]: ereg() does not return TRUE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-66015@lists.php.net to get a copy of this message | ||
ID: 29712
Updated by: vrana@php.net
Reported By: liit at geeksbynature dot dk
-Status: Open
+Status: Closed
Bug Type: Regexps related
Operating System: Gentoo Linux
PHP Version: 4.3.8
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
"If the optional parameter regs was not passed or the length of the
matched string is 0, this functions returns 1."
Previous Comments:
------------------------------------------------------------------------
[2004-09-06 21:27:20] nlopess@php.net
If I understand, this function should return the legth of the match.
But it seems it has a bug, because it always return 1 if you don't pass
the 3rd parameter. Or is it a feature that should be documented?
<?
echo ereg('foo', 'foo foo foo'); //1
echo ereg('foo', 'foo foo foo', $var); //3
echo ereg('foobar', 'foobar foo foo', $var2); //6
?>
Nuno
------------------------------------------------------------------------
[2004-08-29 18:10:00] liit at geeksbynature dot dk
ereg() still only returns int(1) or (boolean)FALSE. I've expanded my
test-script a bit:
<?php
$a = ereg("fo","fo"); // Simple test to see if documentation is right
(it's not)
$b = ereg("bar","foobarbar"); // Is it the position of the first
result, that is returned ? (no)
$c = ereg("foo","bar"); // A negative test (works)
echo $a . ":" . gettype($a). "\n";
echo $b . ":" . gettype($b). "\n";
echo $c . ":" . gettype($c). "\n";
?>
Result:
1:integer
1:integer
:boolean
According to the docs, it should be:
2:integer
3:integer
:boolean
------------------------------------------------------------------------
[2004-08-17 00:40:12] tomsommer@php.net
This bug has been fixed in the documentation's XML sources.
The changes may not appear immediately, since the online and
downloadable versions of the documentation need some time to get
updated. We would therefore like to ask for your patience in this
matter.
Thank you for the report, and for helping us make our documentation
better.
------------------------------------------------------------------------
[2004-08-17 00:12:47] iliaa@php.net
ereg() returns the length of the matched string on success,
the documentation is wrong.
------------------------------------------------------------------------
[2004-08-16 20:57:24] liit at geeksbynature dot dk
Description:
------------
The function ereg() either returns (boolean)FALSE or (int)1, and not
(boolean)FALSE or (boolean)TRUE
Reproduce code:
---------------
echo gettype(ereg("foo","foo"));
echo gettype(ereg("foo","bar"));
Expected result:
----------------
boolean
boolean
Actual result:
--------------
integer
boolean
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29712&edit=1