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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniuf at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 22:01:31 2024 UTC