[thelist] PHP - strings and integers

Lachlan Cannon luminosity at members.evolt.org
Tue Apr 9 00:28:00 CDT 2002


Shashank Tripathi said:
> Hi Lach,
>
>
>    | php, so it comes originally as a string. This presents a
>    | problem, because I can't test to see if the number passed
>
>
> What is your purpose in testing the type of a variable? In PHP, a
> variable does not require formal declaration, it will automatically be
> declared when a value is assigned to it. So if your variable contains a
> substring of the slashed-string that you pass as a part of the URL,
> then that variable will automatically be an integer (assuming you do
> the splitting right).


Because if I treat it as a number, it's converted to one, whether it really
was one or not. For example '13 weeks' is ocnverted to straight 13. But if
they have entered in something incorrect for the field, which should be
strictly numeric I want to redirect to a 404 page. Is that better explained?

Lach





More information about the thelist mailing list