如果您想要一个空字符串默认值,那么首选方法是其中之一(取决于您的需要):
$str_value = strval($_GET['something']);
$trimmed_value = trim($_GET['something']);
$int_value = intval($_GET['somenumber']);
如果 url 参数something 中不存在 url则将$_GET['something'] 返回null
strval($_GET['something'])-> strval(null)->"" 
并且您的变量$value设置为空字符串。
trim()根据代码,可能更喜欢strval()使用它(例如,名称参数可能想要使用它) 
intval()如果只需要数值并且默认为零。intval(null)->0 
需要考虑的案例:
...&something=value1&key2=value2(典型的)
...&key2=value2(url $_GET 中缺少的参数将为其返回 null)
...&something=+++&key2=value(参数为"   ")
为什么这是首选方法:
- 它整齐地放在一条线上,并且很清楚发生了什么。
 
- 它的可读性比
$value = isset($_GET['something']) ? $_GET['something'] : ''; 
- 降低复制/粘贴错误或拼写错误的风险:
$value=isset($_GET['something'])?$_GET['somthing']:''; 
- 它与旧的和新的 php 兼容。
 
更新
严格模式可能需要这样的东西:
$str_value = strval(@$_GET['something']);
$trimmed_value = trim(@$_GET['something']);
$int_value = intval(@$_GET['somenumber']);