This problem is a bit strange. Why is showed "Is not null", if the value sent is null? Any reason for that?
Parametersapplication/x-www-form-urlencoded
lists_owned null
Source
lists_owned=null
<?php
$lists_owned = $_POST['lists_owned'];
var_dump($lists_owned); // string(4) "null"
if(!is_null($_POST['lists_owned'])) {
echo "Is not null"; I see this echo
}
?>
thanks
"null"
is not null
. If you want to check for "null"
then you should be using equality.
if($_POST['lists_owned'] != 'null') {
This is because your post value is a string called 'null' and not an actual null value.
Looks like your value is actually the string "null", not the value null. Ie
<?php
$x = "null";
$y = null;
var_dump($x);
var_dump($y);
?>
Output
string(4) "null"
NULL
$_POST['lists_owned']
is set before accessing it :$lists_owned = isset($_POST['lists_owned']) ? $_POST['lists_owned'] : null;
and only use the$lists_owned
variable after that, it's useless to set $lists_owned and to never use it - mamadrood 2012-04-04 02:31