php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66494 preg_match not working as expected
Submitted: 2014-01-16 04:01 UTC Modified: 2014-01-23 01:23 UTC
From: daniuf at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.4.24 OS: CentOS release 5.10 (Final)
Private report: No CVE-ID: None
 [2014-01-16 04:01 UTC] daniuf at gmail dot com
Description:
------------
When trying to use preg_match I'm not getting the expected result. As you can see, $chiche var should have one element, and it's empty. I've tested same script with version 5.3.3 and works perfectly fine. Also, I'm not getting any error, although I've setted up error_reporting(E_ALL).
Best regards!

Test script:
---------------
<?php

error_reporting(E_ALL);

$res = "hola";
$res = preg_match("/hola/", $res, $chiche);

var_dump($chiche);

Expected result:
----------------
I expect to see :

array(1) {
  [0]=>
  string(4) "hola"
}





Actual result:
--------------
I see:

 array(0) { 

}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-16 04:12 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-01-16 04:12 UTC] requinix@php.net
Works fine for me too. You're saying that if you execute that exact code with your 5.4.24 it doesn't work? Nothing's been omitted?
 [2014-01-16 14:43 UTC] daniuf at gmail dot com
-Status: Feedback +Status: Open
 [2014-01-16 14:43 UTC] daniuf at gmail dot com
Hi requinix.
Thanks for the quick response. Unfortunately, nothing's been omitted.
 [2014-01-19 14:54 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2014-01-19 14:54 UTC] felipe@php.net
This makes no sense, what about using /.+/ pattern for testing?
 [2014-01-23 01:23 UTC] daniuf at gmail dot com
-Status: Feedback +Status: Closed
 [2014-01-23 01:23 UTC] daniuf at gmail dot com
It works when I execute "php -f filename.php" on command line. Thought still not working with web access I'm closing down the ticket.
Thanks anyway!
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Sep 22 09:01:23 2020 UTC