PHP String “0″ or empty issue

Given example an empty value of array like:

Model_x Object ( 
	[_is_new:protected] => [_frozen:protected] => [_data:protected] => 
	Array ( 
		[track_value] => 
		)
	)

When processed the array and $value = $x->track_value

	if($value == 1){
		$returnValue = "Automatic";
	}else if($value == 0){
		$returnValue = "Manuals";
	}else{
		$returnValue = "Undefined";
	}

Output value will be always “Manuals”.

To fix this issue, add “” into the “1″ or “0″

By Keenlio, April 15, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


5 + = fourteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>