Doc #71800 [Opn->Nab]: string checks is_array enters into if and makes that string null
| From: | requinix@php.net | Date: | Fri, 11 Mar 2016 12:43:35 +0000 |
| Subject: | Doc #71800 [Opn->Nab]: string checks is_array enters into if and makes that string null | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13316@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71800&edit=1
ID: 71800
Updated by: requinix@php.net
Reported by: muhammadhu dot aiman at gmail dot com
Summary: string checks is_array enters into if and makes that
string null
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Arrays related
Operating System: Ubuntu 15.04
PHP Version: 5.6Git-2016-03-11 (snap)
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Your code is passing in an array, not a string. PHP itself did not change $str.
Previous Comments:
------------------------------------------------------------------------
[2016-03-11 12:32:24] muhammadhu dot aiman at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.is-array
---
although only array should become true and should enter inside the if, but strings enter into the
is_array() and string is converted into null array.
Test script:
---------------
//a string is passed to the checkString
protected function checkString($str)
if(is_array($str)) { //only arrays allowed here but string goes into if
var_dump($str);exit; //string enters here and $str becoumes a null array
} else {
echo 'ok';
}
}
result is array(0) { }
Expected result:
----------------
protected function checkString($str)
if(is_array($str)) { //only arrays allowed here but string goes into if
var_dump($str);exit; //string enters here and $str becoumes a null array
} else {
echo 'ok';
}
}
result should be 'ok'
Actual result:
--------------
array(0) { }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71800&edit=1