php-src icon indicating copy to clipboard operation
php-src copied to clipboard

'\0' is 0 or !0

Open wuyx1 opened this issue 4 years ago • 1 comments

Description

The following code:

<?php
	$str = '\0';
	$n = 0;
	$flag = ($str == $n);
	echo $flag, "\n";
	if ($str)
	{
		echo "yes\n";
	}
	else
	{
		echo "no\n";
	}
?>

Resulted in this output:

1
yes

But I expected this output instead:

PHP Version

PHP5.4.16

Operating System

centos7

wuyx1 avatar Mar 28 '22 13:03 wuyx1

Hi @wuyx1! This hasn't been the case since PHP 8.0. https://3v4l.org/JZOtk Support for PHP 5.4 is long long gone.

iluuu1994 avatar Mar 28 '22 14:03 iluuu1994