|  | Posted by Mike P2 on 05/16/07 19:52 
On May 16, 1:28 pm, Ming <minghu...@gmail.com> wrote:> private fields declaration like Java
 >
 > require 'XML/RPC.php';
 > ...
 >
 > private XML_RPC_Client $Client;
 >
 > I know I can do
 >
 > private $Client;
 >
 > Thanks,
 
 You cannot do it exactly the same as in Java, but you don't really
 need to worry about doing that in PHP. If you want, you can initialize
 it with "$Client = new XML_RPC_Client();" but that's unnecessary. You
 might as well just do "private $Client;" to make the field and then
 "$Client = new XML_RPC_Client();" in a method. If you are concerned
 because you are taking the object as an argument and setting $Client
 to that, you can be selective with your arguments (in PHP5+) like:
 
 public function setClient( XML_RPC_Client $argClient )
 {
 $this->Client = $argClient;
 }
 
 Note that you don't need to use =& in PHP5.
 
 -Mike PII
 [Back to original message] |