#50801 [Bgs]: Concatenate null values gives an empty string

From: Date: Tue, 19 Jan 2010 17:20:07 +0000
Subject: #50801 [Bgs]: Concatenate null values gives an empty string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146805@lists.php.net to get a copy of this message
ID: 50801 Updated by: rasmus@php.net Reported By: public at proside dot fr Status: Bogus Bug Type: Scripting Engine problem Operating System: WIN XP SP3 PHP Version: 5.3.1 New Comment: No, the '.' operator is defined as the string concatenation operator. Just like using it to concat numbers will cast the numbers to strings, using it to concat nulls will cast the nulls to strings and when you cast a null to a string you get an empty string. Previous Comments: ------------------------------------------------------------------------ [2010-01-19 17:18:35] pajoye@php.net php -r 'echo NULL;' ------------------------------------------------------------------------ [2010-01-19 17:16:49] public at proside dot fr Description: ------------ When you concatenate only NULL values, you got an empty string Reproduce code: --------------- $a = NULL; $b = NULL; $c = $a . $b; echo (is_null($c)) ? 'TRUE' : 'FALSE'; Expected result: ---------------- TRUE Actual result: -------------- FALSE If you look : $c = "" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50801&edit=1

« previous php.bugs (#146805) next »