PHP typing issues

software development

#1

Scripts which through differently typed variables attempt something similar to comparing ‘1’ == 1, cause the script to bomb. Now if they simply bombed that would be fine (although I don’t have these issues in my test environment), but insteqad end up with "Internal Server Error"s. As I’m sure you can appreciate, that’s a pain to debug, as you don’t know where in the script your problem is, or what it is in the first place. And the logs, all they told me was “Premature end of script headers: /dh/cgi-system/php5.cgi”. Go figure.

Does anyone know how to get informative errors in this type of situation?

Ta,
Rhino


#2

I believe that’s a type casting issue.
Your best bet would be reading php5 documentation at php.net

Don’t quote me on this, but you either want to use a triple = (===) for type comparison, or you need to do something like ‘1’ === (string) 1

Or… something like that.

I’ve seen it around, but haven’t had a chance to dabble in it myself yet.

Look around a bit!


#3

Thanks, VxJasonxV

== looks for value likeness.
=== looks for value and type likeness.

I resolved my issue with (int)‘1’ == 1, so I know how to get around it. My issue was with the bizaar error generated.

Ta,
Rhino