Should I typecast in PHP when defining my vars?
Posted
by Borislav
on Stack Overflow
See other posts from Stack Overflow
or by Borislav
Published on 2010-03-22T11:04:50Z
Indexed on
2010/03/22
11:11 UTC
Read the original article
Hit count: 384
I am sorry if this is more of a theory question then a real life problem but it is a real life situation for me. We were commenting on the way PHP works with vars and how memory heavy it is on the server due to its "mixed vars" and something occured to me - why not typecast right from the start?
So I guess my quesion is: Whould it make any difference for the server load if all you PHP vars were"pre-casted"?
Example:
protected $_id;
VS protected (int) $_id;
© Stack Overflow or respective owner