Re: Data Types Problem

From: Date: Tue, 13 Mar 2007 14:23:06 +0000
Subject: Re: Data Types Problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-250424@lists.php.net to get a copy of this message
Richard Lynch wrote: > By definition, all HTTP data is of type 'string' because that's the > ONLY data type HTTP supports. > > PHP will cheerfully typecast it to whatever it needs to be later, but > when it first comes in from the GET (or POST or COOKIE or whatever) > data, it's going to start its life as a string, no matter how it > looks. > > If you *know* it should be integer, typecast it as you get it: > > $foo = (int) $_GET['foo']; > > Do this to a) self-document your code, b) foil a ton of web-bots and > nasty people trying to cram the wrong kind of data into your > application to break/abuse it. > you forgot c. c) because it's what all the cool kids do. actually forget c. cool kids aren't writing code, they're all smoking crack, driving 100,000 dollar cars and pimping out college girls. here's hoping your day is better than mine :-P

« previous php.general (#250424) next »