關於解決PHP報錯“Notice:Use of undefined constant error” 解決辦法


<?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;
 }
}

?>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章