#38715 [Opn->Fbk]: preg_match fails if combined with file_get_contents directly!
| From: | tony2001@php.net | Date: | Mon, 04 Sep 2006 20:19:31 +0000 |
| Subject: | #38715 [Opn->Fbk]: preg_match fails if combined with file_get_contents directly! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101725@lists.php.net to get a copy of this message | ||
ID: 38715
Updated by: tony2001@php.net
Reported By: nino at recgr dot com
-Status: Open
+Status: Feedback
Bug Type: Network related
Operating System: Windows XP
PHP Version: 5.1.6
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
Previous Comments:
------------------------------------------------------------------------
[2006-09-04 19:43:16] nino at recgr dot com
Description:
------------
When you put file_get_contents('some_file.ext') as a second argument in
preg_match() it doesn't work. However, when you put that
file_get_contents() into a variable, and THEN you insert that variable
as a second argument, it works. At least at remote files (I'm not sure
about local files) and when there is a third argument too.
Reproduce code:
---------------
preg_match("<pattern>", file_get_contents('http://www.example.com'),
$found);
Expected result:
----------------
Found matches in array $found.
Actual result:
--------------
Nothing.
However, when put your script thus:
$url = file_get_contents('http://www.example.com');
preg_match("<pattern>", $url, $found);
then it works.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38715&edit=1