Re: Java - toString() <-> php - ?

From: Date: Sun, 07 Aug 2005 20:28:59 +0000
Subject: Re: Java - toString() <-> php - ?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-220184@lists.php.net to get a copy of this message
If you use PHP 5 just use the __toString() magic method which does exactly that. http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring Jasper Rory Browne wrote:
Um - did you read my last email regarding var_dump var_export and print_r Did you try them? Do they do what you want? On 8/2/05, Adi Zebic <adi@beeznest.net> wrote:
Rory Browne a écrit :
I haven't a monkies what that code(your java) does, and I don't have time to analyse it(in expensive cybercafe), but you may want to consider www.php.net/print-r www.php.net/var-dump and www.php.net/var-export I think they may do what you want without using the toString method, which for what you're describing is basicly an ugly hack. One more thing: Enlighten me: What exactly do you mean by "live evolution" in your php/java context.
If in php context you have class, say, A: class A { var $t1; var $t2; var $t3; //After, you have object contructor of type A //we have something like this function A ($var1, $var2, $var3) {
      $this -> t1 = $var1;
      $this -> t2 = $var2;
      $this -> t3 = $var3;
} ....some other code } //than in some other class we have something like this: class someOtherClass {
      $aConstructor = new A(1,2,3);
      //values of t1, t2 and t3 are 1,2 and 3 now
} Right? yes. How you can you do something like this inside of "someOtherClass" print ($aConstructor); to finally have some nice output like Value of t1 is 1; Value of t2 is 2; Value of T3 is 3; or just: 1 2 3 Without creating functions like getValues() function getValues() {
      print ($this -> t1);
      print ($this -> t2);
      print ($this -> t3);
} and after explicit invoke function: $aConstructor -> getValues(); So, what I want is this: print ($aConstructor); and not this: $aContructor -> getValues(); Am I clear :-) ADI -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#220184) next »