Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Form Ajax
#7

[eluser]spfortier[/eluser]
You don't necessarily need to use private, it just provides a level of security to keep you from accidentally overwriting the value stored in the variable as it hides the variable from anything outside the class. It also promotes a better programming style. I generally use "getters" and "setters" to pass values to and from my models.

Code:
class Test {
  private $test_var;

  public function setTestVar($test_var) {$this->test_var = $test_var;}
  public function getTestVar() {return $this->test_var;}
}

$test = new Test();
$test->setTestVar('Hello world!');
echo $test->getTestVar();


Messages In This Thread
Codeigniter Form Ajax - by El Forum - 10-02-2012, 09:10 PM
Codeigniter Form Ajax - by El Forum - 10-02-2012, 09:34 PM
Codeigniter Form Ajax - by El Forum - 10-02-2012, 09:47 PM
Codeigniter Form Ajax - by El Forum - 10-03-2012, 04:08 PM
Codeigniter Form Ajax - by El Forum - 10-03-2012, 05:44 PM
Codeigniter Form Ajax - by El Forum - 10-03-2012, 06:13 PM
Codeigniter Form Ajax - by El Forum - 10-03-2012, 06:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB