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

From: Date: Tue, 15 Sep 2015 18:01:20 +0000
Subject: Bug #50801 [Com]: Concatenate null values gives an empty string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196018@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50801&edit=1 ID: 50801 Comment by: hablutzel1 at gmail dot com Reported by: public at proside dot fr Summary: Concatenate null values gives an empty string Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: WIN XP SP3 PHP Version: 5.3.1 Block user comment: N Private report: N New Comment: Quoting: "when you cast a null to a string you get an empty string". Is there any formal documentation on this?. Previous Comments: ------------------------------------------------------------------------ [2010-01-19 17:20:06] rasmus@php.net 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. ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=50801&edit=1

« previous php.bugs (#196018) next »