ID: 29712
Updated by: [EMAIL PROTECTED]
Reported By: liit at geeksbynature dot dk
Status: Open
-Bug Type: Documentation problem
+Bug Type: Regexps related
Operating System: Gentoo Linux
PHP Version: 4.3.8
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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] [EMAIL PROTECTED]
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] [EMAIL PROTECTED]
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