<?php
class FileUpLoad{private $error;//错误代码
public function __construct($_file){
$this->error=$_FILES[$_file][error];
echo $this->error;
}
}
?>
因为error 没有加上单引号 当打印出来的时候会提示
报错:Notice: Use of undefined constant error - assumed 'error' in C:\wamp\www\yianshujuku\common\FileUpload.class.php on line 6,最好加上单引号
即下面所示:
<?php
class FileUpLoad{private $error;//错误代码
public function __construct($_file){
$this->error=$_FILES[$_file][‘error’];
echo $this->error;
}
}
?>
本文介绍了一个简单的PHP文件上传类,并针对构造函数中出现的未定义常量错误进行了修正,通过添加适当的单引号来避免了该错误。

1269

被折叠的 条评论
为什么被折叠?



