0

Weird parser errors:

Notice: Undefined property: template::$param in 
    C:\xampp\htdocs\app\includes\classes\class.template.php on line 37

Warning: array_keys() expects parameter 1 to be array, null given in 
    C:\xampp\htdocs\app\includes\classes\class.template.php on line 37

Notice: Undefined property: template::$param in 
    C:\xampp\htdocs\app\includes\classes\class.template.php on line 37

Warning: array_values() expects parameter 1 to be array, null given in 
    C:\xampp\htdocs\app\includes\classes\class.template.php on line 37

Code:

public function newParam($trans, $value) {
    $this->param['{' . $trans . '}'] = $value;
}

public function getParam($content) {
    $content = str_replace(
        array_keys($this->param), 
        array_values($this->param), 
        $content
    );

    return $content;
}

Please note that this isn't any existing parser.

3
  • It appears that for some reason, your $this->param is null. Commented May 11, 2014 at 2:43
  • In addition to what you have here, we need to see the code where you are actually instantiating this class and calling getParam(). It would seem that $this->param is not initialized at the time getParam() is called. Is the $param property initialized as a class property, as in public $param = array();? Commented May 11, 2014 at 2:43
  • Please post the entire class declaration. I'm particularly interested in what $this->param contains. Commented May 11, 2014 at 2:43

2 Answers 2

2

Init your "param":

function __construct() {
  $this->param = array();
}

You may also see the PHP Doc

Creating/modifying with square bracket syntax

An existing array can be modified by explicitly setting values in it.

This is done by assigning values to the array, specifying the key in brackets. The key can also be omitted, resulting in an empty pair of brackets ([]).

$arr[key] = value;
$arr[] = value;
// key may be an integer or string
// value may be any value of any type
Sign up to request clarification or add additional context in comments.

Comments

1

Make sure fideloper/proxy version is 4.0 for laravel >= 5.5

"require": {
        "php": "^7.1.3",
        "**fideloper/proxy**": **"^4.0"**,

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.