不灭的焱

加密类型:SHA/AES/RSA下载Go
复合类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel)、接口(interface)、数组(array)、结构体(struct) Go类型+零值nil
引用类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel) Go引用

作者:AlbertWen  添加时间:2015-07-06 12:36:15  修改时间:2025-12-06 02:47:27  分类:11.PHP基础  编辑
<?php
if (!empty (get_gpc('userId'))) {
	$userId = get_gpc('userId');
} else {
	$error = "ID doesn't exist";
}

报错:

Fatal error: Can't use method return value in write context in (line number)

为什么?

empty()函数是检查一个变量是否为空,但是 get_gpc() 是个函数,所以得改下,参考代码如下:

<?php
$test = get_gpc('userId');
if (!empty($test)) {
	$userId = get_gpc('userId');
} else {
	$error = "ID doesn't exist";
}