php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70608 Echo dosn't print false
Submitted: 2015-09-30 12:48 UTC Modified: 2015-09-30 12:58 UTC
From: khaweronline at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.13 OS: ALL OS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: khaweronline at gmail dot com
New email:
PHP Version: OS:

 

 [2015-09-30 12:48 UTC] khaweronline at gmail dot com
Description:
------------
<?php

$a = 12;
$b = 15;

echo $a==$b; // This should output false or 0, but it didn't output anything
var_dump($a==$b); /* This will output Boolean false. This is just for reference that the value is false */

// We can also assign it to a variable then echo and var_dump
$c = $a==$b;

echo $c; // This should output false or 0, but it didn't output anything
var_dump($c); /* This will output Boolean false. This is just for reference that the value is false */


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-30 12:58 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2015-09-30 12:58 UTC] bwoebi@php.net
var_dump((string) false);
prints string(0) "", as the string representation of false is actually an empty string.

Hence echoing it actually prints nothing.
 [2015-09-30 12:59 UTC] php at sogetthis dot com
From the documentation: "A boolean TRUE value is converted to the string "1". Boolean FALSE is converted to "" (the empty string)."

http://php.net/manual/en/language.types.string.php#language.types.string.casting

You could do:
echo $a == $b ? '1' : '0';
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 05:00:01 2026 UTC