php方法意外t_string [重复]

This question already has an answer here:

I am working on a php method that giving me a syntax error on the third line of the method body. Commenting out the line does not do anything for me. Only by commenting out the entire method, does it actually go away. Am I missing something here?

public function get(Array $array) {
    if(array_key_exists('data', $array)) {
        if($array['data'] == '*') {
            $fieldString = '*';
        } else { 
            $fieldString = '';
            for($x=0; $x < count($array['data']); $x++) {
                if($x == count($array['data']) - 1 ) {
                    $fieldString .= $array['data'][$x].' ';
                } else {
                    $fieldString .= $array['data'][$x].', ';
                }
            }
        }
        if(array_key_exists('table', $array)) {
            $table = $array['table'];
        }
        if(array_key_exists('conditions', $array)) {
            $condition = $array['conditions'];
            $filter = '';
            foreach($condition['cond'] as $cond) {
                if(array_key_exists('type', $cond)) { 
                    $filter .= $cond['type'].' ';
                }
                if(array_key_exists('field', $cond)) {
                    $filter .= $cond['field']. ' = '; 
                }
                if(array_key_exists('value', $cond)) {
                    $filter .= $cond['value'];
                }
            }
        }

        $result = $mysqli->query("SELECT ".$fieldString." FROM ".$table. " ".$filter);
        $response = $result->fetch_assoc();
        if(!empty($response)) {
            return $response;
        } else {
            echo 'response array from get model is empty';
        }
    } else {
        echo '<h3>array data not set for _get() in model </h3>';
    }    
}
</div>

Is the method contained within the class. Sometimes I accidentally put a class function at the end of the class file but outside the ending }. If it is not a class method, remove 'public'.

Change $mysqli->query() to $this->mysqli->query()

I am presuming you created a class method mysqli but you are calling it without '$this'. If mysqli is the php function, it should be mysqli_query($this->token, "query")

Although, you should be getting ' Undefined variable' with this. In any event $mysqli is undefined in this method.