PHP typecasting

后端 未结 6 1281
生来不讨喜
生来不讨喜 2020-12-05 06:46

I was wondering what is the best way to typecast a value from one type to another.

Which variant should we use:

  1. intval($value);
  2. <
6条回答
  •  情深已故
    2020-12-05 07:28

    The answer here is to use whatever reads "cleaner" to you. Any difference in speed is going to be so minor, that worrying about it is almost certain to cost you more time than you are liable to save. What will save time, however, is having code that you can read and understand in the future.

    There's an excellent article explain this very thing at Coding Horror.

提交回复
热议问题