簡體   English   中英

檢查數組是否為空或未在php中設置?

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

我目前正在使用:

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

但我也希望它包含一種檢查$get['when'] is empty('') 如何以最佳方式做到這一點?

如果$get['when']為空字符串,則empty( $get['when'] )將返回true 有關更多信息,請參見本手冊的empty條目

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

在檢查$ _GET ['when']設置后,立即使用函數。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM