In PHP is it better to convert a value to an integer using the syntax
(int)$value
or
intval($value)
the question is also be relevant to string, bool, float
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is negligible difference between the two. Even with completely unrealistic scenarios (100k’s loops) you save milliseconds at best.
Do milliseconds matter? Yes. Is this ever going to be the biggest candidate for optimization in your app? No.
Pick the one with the syntax you prefer.