1

PHP CODE

class XXX{
public function ggGet($str){
    return gGet($str); // This is ok working gGet is global function
}
public static $Array = array ( "value" => $this->ggGet("email")); // This code is error Why?

}

I must use a function in array in class.

I see this error.

Parse error: syntax error, unexpected '$this' (T_VARIABLE) in /var/www/html/

What must i do?

Thank you.

0

1 Answer 1

2

Try this:

class XXX{

   $MyArray = array(); 

   public function __construct(){
      $this->MyArray["value"] = $this->ggGet("email");
   }

   public function ggGet($str){
       return gGet($str); 
   }

}

Use __construct() every time you need to start values in a var inside a class.

Sign up to request clarification or add additional context in comments.

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.