Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 类->数组未定义索引 这还没有解决_Php_Class - Fatal编程技术网

Php 类->数组未定义索引 这还没有解决

Php 类->数组未定义索引 这还没有解决,php,class,Php,Class,我有一门课,我已经为我做了一个积垢。以下是适用于我的问题的部分 我返回以下错误 [07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: placeholder in class/LeadStages.php on line 88 [07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: id in class/LeadS

我有一门课,我已经为我做了一个积垢。以下是适用于我的问题的部分

我返回以下错误

[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice:  Undefined index: placeholder in class/LeadStages.php on line 88
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice:  Undefined index: id in class/LeadStages.php on line 90
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice:  Undefined index: type in class/LeadStages.php on line 91
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice:  Undefined index: maxchar in class/LeadStages.php on line 93
阶级

var_dump$期权的结果

我正在使用的FormFields类函数

function InputError_NEW($Error, $Value, $PlaceHolder, $InputName, $InputID, $InputType, $InputLabel, $MaxChar,$required) {
        $output = '<div class="control-group">';
        if (!empty($Error)) {
                $output .='<label class="control-label" for="inputError">
                    <i style="color:red" class="fa fa-times-circle-o">
                        <b>'.$Error.'</b>
                    </i>
                </label>';  
        }
        $output .='<label class="control-label">' . $InputLabel . '</label>' .
                '<div class="controls">' .
                '<input class="form-control"';
                    if (!empty($InputID)) {
                        $output .= ' id="' . $InputID . '"';
                    }
                    if (!empty($InputName)) {
                        $output .= ' name="' . $InputName . '"';
                    }
                    if (!empty($InputType)) {
                        $output .= ' type="' . $InputType . '"';
                    }
                    if (!empty($PlaceHolder)) {
                        $output .= ' placeholder="' . $PlaceHolder . '"';
                    }
                    if (!empty($Value)) {
                        $output .= ' value="' . $Value . '"';
                    }
                    if (!empty($MaxChar)) {
                        $output .=' maxlength="'. $MaxChar . '"';
                    }
                    if ($required) {
                        $output .= ' required';
                    }
                    $output .= '>' .
                '</div>' .
                '</div>';
        return $output;   // you will have to echo ($output); in the HTML file
    }

    function SelectError_NEW($Error, $InputLabel, $Class, $DataTargetDIVID, $SelectName, $SelectArray, $Value) {
        $output = '<div class="control-group">';
        if (!empty($Error)) {
                $output .='<label class="control-label" for="inputError">
                    <i style="color:red" class="fa fa-times-circle-o">
                        <b>'.$Error.'</b>
                    </i>
                </label>';  
        }
        $output .='<label class="control-label">' . $InputLabel . '</label>' .
                '<div class="controls">' .
                '<select class="form-control ' . $Class . '" data-target="' . $DataTargetDIVID .'" name="' . $SelectName .'"';
                if ($required) {
                $output .= ' required'; 
                }
                $output .='>
                    <option value="">-- Select One --</option>
                    '.makeOptions($SelectArray, $Value).'
                </select>' .
                '</div>' .
                '</div>';
        return $output;   // you will have to echo ($output); in the HTML file
    }

如果您不理解这些评论,我的意思是抱歉

class LeadStage {
    private $my_object;
    function __construct() {
        $this->my_object = new FormFields(); 
    }

    // Input Field -> Stage
    function addInputError_New_Element($option) {
        //$FormFields = new FormFields();
        $element = $this->my_object->InputError_NEW(
    //...............
    //.................

同样,世界各地的情况也一样。要指向变量,请使用$this关键字,您应该在类中包含该变量。

下面的方法旨在对要创建的输入字段进行快速验证。这带来了一个问题,并最终否决了这种方法

function addElementToForm($option) {
        if($option['FormField'] = 'stage') {

            // Build our Markup to input our new stage.
            $element = $this->addInputError_New_Element($option);

        } 
        if($option['FormField'] = 'status') {
            // Build our Markup for selecting our status.
            $element = $this->addSelectNoBlank_New_Element($option);

        }

        return $element;

    }
当我创建makeEntireForm方法时,我创建了一个

$entireForm .= $this->addElementToForm($stage_option);
我把它改成了下面的

$entireForm .= $this->addInputError_New_Element($stage_option);

通过删除此中间人方法,我能够完成我的最终结果。

查看您是否获得了这些值var\u dump$option将其更改为您输入的值,但没有任何更改。同样的错误@Fred ii语法是_构造。你应该更新你的问题,然后我意识到在我说了之后。。我更改了它,现在得到了PHP致命错误:调用未定义的函数FormFields,它来自构造函数PHP致命错误:无法在第18行的/class/FormFields.PHP中重新声明类FormFields,这是类FormFields{…请参阅UoDate代码,如果未解决,请发布您的FormFields类代码。发布类FormFields{…}转到我发送的聊天区@webDevyou正在声明您的类两次,如果您需要或包含类FormFields{…},请删除。我不再收到该错误。我返回原始错误。未加密索引。
function addElementToForm($option) {
        if($option['FormField'] = 'stage') {

            // Build our Markup to input our new stage.
            $element = $this->addInputError_New_Element($option);

        } 
        if($option['FormField'] = 'status') {
            // Build our Markup for selecting our status.
            $element = $this->addSelectNoBlank_New_Element($option);

        }

        return $element;

    }
$entireForm .= $this->addElementToForm($stage_option);
$entireForm .= $this->addInputError_New_Element($stage_option);