タグ

2013年2月18日のブックマーク (1件)

  • PHP: Casting vs. intval()

    Doing a cast like (int) $var instead of the intval($var) function is about 300% to 650% faster. I did some tests out of curiousity in #13317 and those are the results: Running the Tests Speed comparison (int)$val vs. intval($val) [System #1] # INPUT (INT)$val INTVAL($val) RATIO ---------------------------------------------------------------------------- #0 42 : 0.068180 / 0.448819 658% #1 -42 : 0.

    PHP: Casting vs. intval()
    calpo
    calpo 2013/02/18
    (int) vs intval()。 (int)のほうが3-6倍早い。変換結果はどちらも同じ。基数を指定したい場合は intval() の第二引数で。