Welcome Guest, Not a member yet? Register   Sign In
Object inside function - Error: "Using $this when not in object context in..."
#1

[eluser]Muppit[/eluser]
I have a block of code which, using switch case, calls a function depending on a value passed via the URL.

I have loaded the eMail class within my controller, and it works fine - until I try to access the email object within my function, which is being called from the switch case.

Ex:

Code:
switch($a)
  case "add":
  funcName($email, $to);
  break;

function funcName($email, $to){
  $this->email->... // Do all eMail things here
}
Returns this error:

Fatal error: Using $this when not in object context in /file.php on line 119

But place all the code within that function outside of a function and it works perfectly.

So my question is, how do I access that object within a function? Or is it something else I'm not getting?

Appreciate any help on this,

Muppit


Messages In This Thread
Object inside function - Error: "Using $this when not in object context in..." - by El Forum - 05-07-2008, 02:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB