Welcome Guest, Not a member yet? Register   Sign In
Call a variable outide a different class
#4

[eluser]LuckyFella73[/eluser]
@Otemu

That won't work:
Code:
class MyOwnClass extends anotherClass{

public $getUsername = $this->session->userdata('username'); // you can't call classes/ methods when setting class properties!

I didn't test but I think you could do it this way:

Code:
class MyOwnClass extends anotherClass{

public $username = '';

public function __construct()
{
  $this->CI =& get_instance();
  $this->username = $this->CI->session->userdata('username');
}
     public function method1(){

         // do something with $this->username
    }
}


Messages In This Thread
Call a variable outide a different class - by El Forum - 02-19-2013, 11:22 PM
Call a variable outide a different class - by El Forum - 02-20-2013, 03:55 AM
Call a variable outide a different class - by El Forum - 02-20-2013, 04:37 AM
Call a variable outide a different class - by El Forum - 02-21-2013, 03:49 AM
Call a variable outide a different class - by El Forum - 02-21-2013, 04:58 AM
Call a variable outide a different class - by El Forum - 02-21-2013, 10:41 AM
Call a variable outide a different class - by El Forum - 02-22-2013, 02:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB