Broken IF behavior? (Changing the branch changes the evaluation)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Background: I'm converting a webapp from Visual FoxPro as a backend to
MySQL... However one part of our app (a system status checker) is
common code between the versions.

I've got the following function... In English (in case it's not
apparent), if the version of the app is 2.0 or higher, then use MySQL
functions, otherwise use the ODBTP function to connect to VFP.

function my_fetch_array($result)
	{
	global $Version;
	if(version_compare($Version,"2.0",">="))
		{ $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; } }
	else	{ $Ret = odbtp_fetch_array($result); if(!$Ret) { } else { return $Ret; } }
	}

This feels like a hack but works perfectly. Data is returned and all
is right with the world. Until I added in extra "error reporting".
When I change the if(!$Ret) portion as such...

	if(!$Ret) { die("myError".mysql_error()); } else { return $Ret; }

It ALWAYS dies... and I see "myError" on the screen... If I change it
like such...

	if(!$Ret) { } else { echo "notError"; return $Ret; }

I always see the "notError" on the screen and $Ret gets returned.

WHY does adding the die() inside the { } change the way the if is evaluated?

By the way I've tested this on 4.4.x on OSX and Windows, and on 5.2.5
on Windows...

Thanks

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux