a little more info would help.
the only problem I see at the moment is the variable name.
'$this' is an object reference and as such shouldn't be attributed a value.
$this->varname = "value"; would be fine once the object has been instantiated.

what exactly are you trying to achieve?

on a different slant: if your function is not within a class, try globalizing the variable first

Thank you for taking the time to respond. I'm sorry to report that the error was being cause due to a missing quotation mark 3 lines up. I must had looked at it at least 10 times, and never noticed it.