while reading scripts i downloaded here, i noticed that most of the users use *val() (intval,strval,...) funtions to typecast a variable. Well I just wanted to tell them that calling functions in php can slow down your script execution, especially when you can use built-in (int), (string), (bool), and other statements (i dont know how they are called). When casting int type with (int) o a string var it was done 40% faster than using intval() function. But I read that in some cases it can reach up to 350%. So for the sake of your scripts dont use functions to typecast.
about typecasting and script optimization
Collapse
X
-
about typecasting and script optimization
PHP Code:$("#mfreak").find(".head brain").clone();
Code:[|||___________________________] : 5%
Code:Memory limit reached, unable to complete operation.
Code:Try using a super uber strong mega computer to reach at least 10%.
Tags: None
-
Originally posted by arnage View PostDepending. For examle, when/if is needed, the same value can be float and int so can't define both at 4 and 4.4 but intval() is ok with both values.PHP Code:$("#mfreak").find(".head brain").clone();
Code:[|||___________________________] : 5%
Code:Memory limit reached, unable to complete operation.
Code:Try using a super uber strong mega computer to reach at least 10%.
Comment
-
Originally posted by arnage View PostI didn't mention if() anywhere. (int) is int, for example 4, (float) is float, for example 4.4, and intval() is both. So it doesn't do the same thing. Also intval() is commonly used for conversion, not just expected values like (int).PHP Code:$("#mfreak").find(".head brain").clone();
Code:[|||___________________________] : 5%
Code:Memory limit reached, unable to complete operation.
Code:Try using a super uber strong mega computer to reach at least 10%.
Comment
-
You are right, it is one of cases when intval shouldn't be used insted int, simply because if "something unusual" is pased via url intval will convert it but int will set it to 0.
Meybe to be intval() used with abs()... But here would be your question of speed.Last edited by arnage; 18.08.12, 09:59.<!DOCTYPE html PUBLIC "-//WAPFORUM.RS
Comment
Comment