php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15344 TRUE is 1, FALSE ought to be 0, but is actually NULL;
Submitted: 2002-02-02 15:49 UTC Modified: 2002-02-02 18:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: uk at uukk dot f2s dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.0.6 OS: SuSE Linux 7.3
Private report: No CVE-ID: None
 [2002-02-02 15:49 UTC] uk at uukk dot f2s dot com
TRUE is represented as 1, 
FALSE or (boolean)0 ought to be represented as 0, but is 
actually NULL;

This results in numerous side-effects 
such as HTML-tables partially shown, etc ...

<?

	//
	// L206.php
	// 
 
	include("ukFnctLib.php");

	//==================================
	//sample data
	for($no=0;$no<5;$no++)
	{ 
		$arrContact[$no]=
		array
		( 
			"surname"			
	=>"surname".$no, 
			"christianName"	
=>"christianName".$no, 
			"address"			
	=>"address".$no, 
			"country"			
	=>"country".$no, 
			"postcode"			
=>"postcode".$no, 
			"town"				
	=>"town".$no, 
			"phone"				
	=>"phone".$no, 
			"fax"				
		=>"fax".$no, 
			"email"				
	=>"email".$no,
			"age"				
		=>20+$no,
			"height"			
	=>1+$no/10,
			"nice2"				
	=>(($no%2)==0?"TRUE":"FALSE"), 
			"nice1"				
	=>(($no%2)==0?TRUE:(boolean)NULL) 
		)
		; 
	}//for
 
	//==================================
	//the author's way: foreach
	foreach($arrContact as $arrContactKey=>$arrAddress)
	{ 
		foreach($arrAddress as 
$arrAddressKey=>$arrAddressData)
		{ 
			echo $arrContactKey,": 
",$arrAddressKey,": ",$arrAddressData,"<br>"; 
		}//foreach 
		echo "<br>"; 
	}//foreach 

	//==================================
	//uk's way
	ukPrintTable($arrContact);
 
?>

include:

function ukPrintTable($array)
{
	//new table
	echo"<table border=1>";

	//table header
	echo"<th>array key</th>";
	echo"<th>array data type</th>";
	echo"<th>array value</th>"; 

	//table rows
	do
	{
		echo"<tr>";
		echo"<td>",key($array),"</td>";
 
		echo"<td>";
		echo gettype(current($array));
		echo"</td>";

		echo"<td>";
		if(gettype(current($array))=="array")
			ukPrintTable(current($array));
		else
			echo current($array);
		echo"</td>";

		echo"</tr>";
	}while(next($array));

	//end of table
	echo "</table>";
}//uk_print_table 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-02 18:58 UTC] yohgaki@php.net
This is not a bug. Please double-check the documentation available
at http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 23:01:27 2024 UTC