注意:未定义的变量:第18行的C:\ xampp \ htdocs \ mvc \ app \ validation \ DForm.php中的currentValue

时间:2018-10-06 03:41:36

标签: php oop mysqli pdo

我正在开发一个PHP MVC框架。但是,当我插入帖子时,我可以看到此错误。我该如何解决这个错误?我想验证我的输入字段。防止空字段。 Here is my error screenshot

同意我的密码

{{1}}

1 个答案:

答案 0 :(得分:-1)

此行$this->$currentValue = $key;中的错误。因为您在currentValue之前使用$符号。并总是像currentValue一样呼叫$this->currentValue

在此上方替换

$this->currentValue = $key;//remove $ sign before currentValue

还要更正这些功能

  • isEmpty()
  • isCatEmpty()
  • length()

另外,您应该在类中添加ConstructorsDestructors并初始化参数,如

public $currentValue;
    function __construct() {        
        $this->currentValue = "";   //here you can assign value     
    }

如果您想为currentValue动态分配值,则在constructor中传递参数

function __construct($value) {      
            $this->currentValue = $value;   
        }
相关问题