PHP typecasting

后端 未结 6 1283
生来不讨喜
生来不讨喜 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

    I prefer using

    settype($value,getType(intval((int)$value)));
    

提交回复
热议问题