Jump to content

tab4trouble

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by tab4trouble

  1. Dear Zurev, Could you please give me a simple example if possible? Thanks. Regards, tab4trouble
  2. I'm having issues with getter and setter functions in PHP. Following is how I have written my PHP classes. -------------------------------------------------------------------------------------------------------------------- File1.php -------------------------------------------------------------------------------------------------------------------- <?php class TestClass1 { private $var; public function get_varvalue() { return $this->var; } public function set_varvalue($TestVar) { $this->var = $TestVar; } } ?> -------------------------------------------------------------------------------------------------------------------- File2.php -------------------------------------------------------------------------------------------------------------------- <?php $obj = new TestClass1(); $obj->set_varvalue("someText"); ?> -------------------------------------------------------------------------------------------------------------------- File3.php -------------------------------------------------------------------------------------------------------------------- <?php class TestClass2 { $obj2 = new TestClass1(); echo $obj2->get_varvalue(); } ?> File1, File2 and File 3 are separate PHP files. File2 uses the TestClass1 object to set the value to variable 'var' but when I try to get the value print the value in File3.php by creating an object for the same class and calling the get_varvalue() function, I'm getting a blank output. Please help me to solve this issue. Thank you. Regards, tab4trouble
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.