I have a question about passing variables to a method. Let say I have this example
class example
{
var var1;
var var2;
var counter;
function method1($m1,$m2)
{
$this->var1 = $m1;
$this->var2 = $m2;
//
encapuslatedMethod1($this->var1);
printf("Var1 was %d\n",$this->var1);
encapsulatedMethod2($this->var2);
print("Var2 was %d\n",$this->var2);
}
function encapsulatedMethod1($m1)
{
$this->var1 = $m1;
$counter = $this->var1 + 10;
printf("Var1 is now %d\n",$counter";
}
function encapsulatedMethod2($m2)
{
$this-var2 = $m2
$counter = $this->var2 - 10;
print("Var2 is now %d\n",$counter);
}
}
$a = new example();
$a->method1(20,20);
exit(1);
-=-=-=-=-=-=-=-=-
I didn't write php5 syntax by created private methods, because my question is related more to OO programming in general.
Do I need to pass variable with in methods or is there a way to pass object data without adding them as method parameters? This is simple example, but I have a program that is passing vaules from a database for a google adsense configuration.
ie:
$this->buildForm($b->blog_id,$b->ad_client_no,$b->ad_width,$b->ad_height,
$b->ad_format,$b->ad_type,$b->ad_border, $b->ad_bg,$b->ad_link,$b->ad_url,$b->ad_text,$b->enable);
Thanx in advance.
-Marquis