A short tutorial about the use of $this.
class Foo {
private $variable = "Do This";
public static $anotherVariable = "Do That";
function __construct($setVariable) {
$this->variable = $setVariable;
self::$anotherVariable = $setVariable;
}
function string toString() {
return $this->variable + self::$anotherVariable;
}
}
In this example I show both a class variable and an instance variable.
The class variable in this case is noted with the static keyword and has to be accessed as in this example with the self::$another variable. A class variable is the same variable in every object that uses that class. So if you have 3 different objects of type Foo all three have the same value for $anotherVariable. Changing it in any of the objects will change it in every one. You actually do not need to create an object to use a class variable unless the class is an abstract class. You can NOT use self outside of a class because it will do nothing and will throw an error.
In this example you see an instance variable. This variable only exists when we create an object from this class thus creating an instance. Trying to access it directly from the class will throw an error similar to the one mentioned here. When you use the $this keyword it is refering to the object that contains the function that it resides in. I believe in PHP you HAVE to use $this to access the variable listed here as $variable and it can only be used within the class.
As an example with this class:
$newObject = new Foo();
$newObject->$variable = "New value ";
Foo::$anotherVariable = "Another new Value";
echo $newObject->toString();
This would output:
New Value Another new Value
So in your code unless it resides within a class you can not use $this. Use the name of the object you are refering to. So in your example if that function is within $xoopsUser the proper way to use it is:
$xoopsUser -> assign('authorised_groups', array (1));
Also do not forget to use the ';' at the end of the line because it can create weird issues when you forget.
If you are doing this within a class which it does not appear to be the case here based on what you shared then it is likely the missing ';'.
I really should write that tutorial about classes...
Anyhow let me know if this helps...
The error you are getting makes me believe you are trying to use $this outside of a class which is the error you are getting. It has no clue what $this is.