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></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>
以上就介绍了判断是否为数字,时间格式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。