Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Fri Apr 03, 2009 6:10 pm Reply with quote

just wondering if there is a difference between the following 2 examples

Code:



$testy = inval($testy);

$testy = (int) $testy;



Is there any security issue's, or is it just pure prefence based.As (int) seems to be twice as fast.

I couldn't find anything on the php site about it
 
View user's profile Send private message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Fri Apr 03, 2009 9:25 pm Reply with quote

Slightly different output in various edge cases, but functionally they are pretty equivalent. I don't think there are security issues with either
http://us.php.net/manual/en/function.intval.php

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
testy1







PostPosted: Fri Apr 03, 2009 9:29 pm Reply with quote

I guess I will use (int) from now on then.
 
technocrat
Life Cycles Becoming CPU Cycles



Joined: Jul 07, 2005
Posts: 511

PostPosted: Wed Apr 08, 2009 10:24 am Reply with quote

(int) directly type casts the variable and is SLIGHTLY faster in most applications. Books and such on optimization say to use that vs intval. Same with all other conversion functions.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! / Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©