Re: simple oop question: accessor function





> Because you haven't set the value of $toon->a.


the value of $toon->a is set in 'function set_vanA()'.
as far as i understand it, when you call function 'get_vanA()', it should
get automaticaly
the value from '$a' from the 'function set_vanA()';

i have got this from the book 'php and mysql webdevelopment' by Luke Welling
and Laura Thomson (second edition page 150-151);

------------------------- code -------------------------------
<?
class A{
var $a;

function set_vanA(){
$this->a = "hello";
}

function get_vanA(){
return $this->a;
}
}

$toon = new A();

echo $toon->get_vanA();

?>
-----------------------------------------------


.



Relevant Pages

  • Re: simple oop question: accessor function
    ... the strange thing is, when i do it the following way it works fine. ... var $a; ... $toon = new A; ... Prev by Date: ...
    (alt.php)
  • Re: simple oop question: accessor function
    ... > the strange thing is, when i do it the following way it works fine. ... > var $a; ... > $toon = new A; ... Prev by Date: ...
    (alt.php)
  • Re: jscript to find file version
    ... <script language = jscript> ... var version = ... Prev by Date: ...
    (microsoft.public.scripting.jscript)
  • scroll select
    ... arr = getMultiple; ... var keep_array = new Array; ... Prev by Date: ...
    (comp.lang.javascript)
  • Ataturkun gizli vasiyeti
    ... Onlar tam 40 yildir, resmi makamlarin inkarina ragmen, ... "var" dedikleri gizli vasiyetin pesindeler.... ... Prev by Date: ...
    (soc.culture.turkish)

Loading