开发者

Checking if a array is empty or not set in php?

I'm currently using:

if (isset($get['when']) && !strtotime($get['when']) && strtotime($get['when'开发者_高级运维]) < time())

But i would also like it to include a way to check if $get['when'] is empty(''). How do I do this in the best manner?


empty( $get['when'] ) will return true if $get['when'] is an empty string. See the manual's entry on empty for more info.


if (isset($get['when']) && !empty($_GET['when']) && !strtotime($get['when']) && strtotime($get['when']) < time())

Use the empty function straight after you check that $_GET['when'] is set.


if(isset($get['when']) && !empty($get['when']) ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜