php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67480 String E conversion to numbers.
Submitted: 2014-06-19 15:11 UTC Modified: 2014-06-19 17:46 UTC
From: madu dot rapa at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.29 OS: ALL
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: madu dot rapa at gmail dot com
New email:
PHP Version: OS:

 

 [2014-06-19 15:11 UTC] madu dot rapa at gmail dot com
Description:
------------
<?php
$x='E'; // Assignment of Parameter 
if ( $x!='0') // Check if the value is '0' (string)
{
echo "False";
}
else
{
echo "TRUE";
}
?>

Above code returns False while below code returns TRUE for the if condition with a warning message --> Notice: Use of undefined constant E - assumed 'E'

<?php
$x='E'; // Assignment of Parameter 
if ( $x!=0) // Check if the value is 0 (integer)
{
echo "False";
}
else
{
echo "TRUE";
}
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-19 17:46 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-06-19 17:46 UTC] requinix@php.net
I don't get that notice. Are you sure you have $x='E' and not $x=E?

To the point, string <=> integer comparison works by converting the string to an integer; (int)'E' is 0, thus 'E'==0. If you want strict inequality then use !==.
http://www.php.net/manual/en/types.comparisons.php
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 23:00:02 2026 UTC