Welcome Guest, Not a member yet? Register   Sign In
accessing base class variable
#10

[eluser]mehwish[/eluser]
leave the base class concept. Simply i want to know how can I declare a variable so that when I set the variable's value in one method .. I can access the same variable's value from any other method of the same controller's class. I have tried declaring variable private public etc. but a strange behaviour i came to see for example i declare public $vari and assign it the vaue of $email1 in index function. Then from my_profile_page()function I am able to print the value of vari using $this->vari but when i use the same statement in my my_f() function it shows nothing.



Code:
<?php

class Form_Controller extends MY_Controller {

    public $vari;
    function Form_controller()
    {
        parent::Controller();
    }


function index()
{
if ($this->input->post('submitbutton2'))
{
$email1=$this->input->post('email');
  $this->vari=$email1;
}
else $this->load->view('someview')

} // end of index




function my_profile_page($data2=null)
{
echo $this->vari;
}




function  my_f()
    {echo $this->vari;}


Messages In This Thread
accessing base class variable - by El Forum - 06-06-2011, 01:59 AM
accessing base class variable - by El Forum - 06-06-2011, 02:36 AM
accessing base class variable - by El Forum - 06-06-2011, 06:31 AM
accessing base class variable - by El Forum - 06-06-2011, 02:23 PM
accessing base class variable - by El Forum - 06-07-2011, 12:05 PM
accessing base class variable - by El Forum - 06-07-2011, 02:35 PM
accessing base class variable - by El Forum - 06-08-2011, 03:12 AM
accessing base class variable - by El Forum - 06-08-2011, 03:57 AM
accessing base class variable - by El Forum - 06-08-2011, 04:19 AM
accessing base class variable - by El Forum - 06-08-2011, 04:31 AM
accessing base class variable - by El Forum - 06-08-2011, 05:14 AM
accessing base class variable - by El Forum - 06-08-2011, 07:33 AM
accessing base class variable - by El Forum - 06-08-2011, 11:43 PM
accessing base class variable - by El Forum - 06-09-2011, 12:54 AM
accessing base class variable - by El Forum - 06-09-2011, 05:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB