php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63847 wrong warning when using in_array() function with specific parameters
Submitted: 2012-12-24 10:53 UTC Modified: 2013-01-08 03:19 UTC
From: evil0x3a at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.20 OS: Linux
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: evil0x3a at gmail dot com
New email:
PHP Version: OS:

 

 [2012-12-24 10:53 UTC] evil0x3a at gmail dot com
Description:
------------
in_array() function cannot deal with an array that has been declared in an 
included script  , and the compiler shows ths warning :
"PHP Warning:  in_array() expects parameter 2 to be array, null given in ..."




Test script:
---------------
we have 2 files 
file 1 ( arrayFile.php )
----------------------------
<?php

$languages = array('en','fr','es','it','ar','in','ru','jp');

?>
----------------------------
file 2 ( index.php )
----------------------------
<?php
require_once('arrayFile.php');
$language = 'ar';
if(in_array($language,$languages)) 
{
print "200 OK";
} else {
print "404 not found";
}
?>

Expected result:
----------------
i expect that in_array() function returns true while the value of $language is available in $languages directory !

Actual result:
--------------
Returns nothing and provides this warning :
"PHP Warning:  in_array() expects parameter 2 to be array, null given in ..."

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-26 15:37 UTC] reeze@php.net
I can't reproduce it, will you check it again?
 [2012-12-26 15:37 UTC] reeze@php.net
-Status: Open +Status: Feedback -Package: Compile Warning +Package: Scripting Engine problem
 [2013-01-08 03:19 UTC] aharvey@php.net
Works fine here. You have some other problem, most likely with your require_once — check your error reporting settings and try one of the support channels at http://php.net/support if you need further help.
 [2013-01-08 03:19 UTC] aharvey@php.net
-Status: Feedback +Status: Not a bug -Package: Scripting Engine problem +Package: Arrays related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC