Re: PHP: array with null shows different with print_r and var_dump

From: Date: Wed, 02 Apr 2008 06:57:42 +0000
Subject: Re: PHP: array with null shows different with print_r and var_dump
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-272430@lists.php.net to get a copy of this message
On Tue, Apr 1, 2008 at 11:49 PM, Sanjay Mantoor <sanjay.mantoor@gmail.com> wrote: > Hello, > > I am new to PHP and PHP community. > > Following program outputs different values with print_r and var_dump. > > $array = array(null, NULL); > > print_r($array); prints values like below > Array > ( > [0] => > [1] => > ) > print_r converts null, which is a variable type, like integer, string, float, etc, into an empty string. > where as var_dump($array) prints values like below > array(2) { > [0]=> > NULL // Does this convert to null to NULL? null is case-insensitive, so it doesn't matter how you type it. > [1]=> > NULL > } var_dump converts null into the string "NULL". > > Can you tell me why the above difference? > -- -Casey

« previous php.general (#272430) next »