Quote:
Originally Posted by BestXXXPorn
Ouch... no don't do that and if you really must typecast instead use
$val = intval($_POST['variable']);
And always use single quotes unless you need special escaped chars... Every time you use double quotes for a string in PHP you cause the string interpreter to parse the entire string looking for variables, special chars, etc... Using single quotes instead ensures that doesn't happen... 
|
Agreed with the single quotes.. Far too much code out there that uses double quotes.
As for the int thing, let's all argue about how best to handle them lol...
I actually do a preg_match on all values that are supposed to be pure integers so I can catch invalid data. i.e.:
preg_match('/^[+-]?\d+$/', (string)$value)