|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-20 02:40 UTC] derick@php.net
[2002-06-18 18:33 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 22:00:01 2025 UTC |
Hello, In the following example source: <?php class A { var $property = 'string value'; function methodA() { echo "$this->property\n"; } } class B { var $objArray = array(); var $currentObj = 0; function B() { $this->objArray[$this->currentObj] = new A; } function methodB($index = 0) { return $this->objArray[$index]; } } $b = new B; /* * This works: */ $b->objArray[$b->currentObj]->methodA(); /* * But this don't: */ // $b->methodB()->methodA(); ?> Is it possible to get this work? It is something like collections in JScript of Internet Explorer, for example: <HTML> <SCRIPT LANGUAGE="JScript"> function numberCells() { var count=0; for (i=0; i < document.all.mytable.rows.length; i++) { for (j=0; j < document.all.mytable.rows(i).cells.length; j++) { // Looks like rows() is method of mytable and // cells() is method of object returned by rows() document.all.mytable.rows(i).cells(j).innerText = count; // ~~~~~~~ ~~~~~~~~ count++; } } } </SCRIPT> <BODY onload="numberCells()"> <TABLE id=mytable border=1> <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> </TABLE> </BODY> </HTML> The following example works in PHP3, but not in PHP4: <?php class A { var $var = 'some value'; } class B { var $date = date('Y.m.d'); var $a = new A; } ?> Is it possible to get it work in PHP4? Maybe, in the future versions of PHP4? If it's possible let me know about this. Ramunas P.s. Sorry for my English.