<?php
echo $Variable;
?>
**// I would like to check if the variable is empty, using but if() statements but more secure than...**
if($var == "")
是否有可能檢查變量是否比這更安全?如何判斷變量是否爲空?
<?php
echo $Variable;
?>
**// I would like to check if the variable is empty, using but if() statements but more secure than...**
if($var == "")
是否有可能檢查變量是否比這更安全?如何判斷變量是否爲空?
if(!isset($var) || $var == "")
{
//$var is empty.
}
^這就是我使用,它也包括如果你還沒有 '初始化' 呢。
*編輯 - 反映意見
我會用空字符串檢查翻轉'isset()',這樣如果變量沒有設置,你就不會收到錯誤。另外,我會在'$ var'周圍添加'trim()'去除任何空白 – Patrick
試試這個isset作爲函數
isset($variable)
使用isset
if(empty($ var)) – stecb
您擔心什麼安全問題? – aaz
Wellthat人們可能會通過它破解,儘可能保證安全。 –