Tuesday, 6 August 2013

Using a PHP OOP Method more than once

Using a PHP OOP Method more than once

Hi Everyone I'am new to OO PHP and I want to have a function and then use
it multiple times with different parameters
For example
<?php
class Test {
var $test;
public function func($val) {
$this->test = $val;
}
public function buildFunc() {
if(!empty($this->test)) {
$ret = $this->test;
}
return $ret;
}
}
?>
Then on calling page.
$test = new Test;
$test->func("test1");
$test->func("test2");
echo $test->buildFunc();
Then It prints test2 on the screen. And I want it to print out both of them.

No comments:

Post a Comment