is_numeric();
<code><span><span><?php</span><span>$tests</span> = <span>array</span>( <span>"42"</span>, <span>1337</span>, <span>"1e4"</span>, <span>"not numeric"</span>, <span>array</span>(), <span>9.1</span> ); <span>foreach</span> (<span>$tests</span><span>as</span><span>$element</span>) { <span>if</span> (is_numeric(<span>$element</span>)) { <span>echo</span><span>"'{$element}' is numeric"</span>, PHP_EOL; } <span>else</span> { <span>echo</span><span>"'{$element}' is NOT numeric"</span>, PHP_EOL; } } <span>?></span></span></code>
結果
<code><span>'42'</span><span>is</span> numeric <span>'1337'</span><span>is</span> numeric <span>'1e4'</span><span>is</span> numeric <span>'not numeric'</span><span>is</span><span>NOT</span> numeric <span>'Array'</span><span>is</span><span>NOT</span> numeric <span>'9.1'</span><span>is</span> numeric</code>
strtotime($time)
<code><span>$time</span> = <span>'2015adsasd'</span>; var_dump(strtotime(<span>$time</span>)); <span>$time1</span> = <span>'2015-01-11'</span>; var_dump(strtotime(<span>$time1</span>));</code>
結果
<code><span>bool</span>(<span>false</span>) <span>int</span>()</code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了判斷是否為數字,時間格式,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。