473,671 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I do this in php5?

private fields declaration like Java

require 'XML/RPC.php';
....

private XML_RPC_Client $Client;

I know I can do

private $Client;

Thanks,

May 16 '07 #1
4 1455
Ming wrote:
private fields declaration like Java

require 'XML/RPC.php';
...

private XML_RPC_Client $Client;

I know I can do

private $Client;

Thanks,
No. PHP is untyped; $Client can be anything. Just assign a new
XML_RPC_Client to $Client in your constructor.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 16 '07 #2
On May 16, 1:28 pm, Ming <minghu...@gmai l.comwrote:
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

May 16 '07 #3
On May 16, 1:28 pm, Ming <minghu...@gmai l.comwrote:
private fields declaration like Java

require 'XML/RPC.php';
...

private XML_RPC_Client $Client;

I know I can do

private $Client;

Thanks,
Not in that context. Besides, why would you want to? Don't you trust
yourself to put the right thing in there? :)

Having said that, PHP allows you to specify the class of an argument
to a function. See this:

<http://www.php.net/manual/en/language.oop5.t ypehinting.php>

May 16 '07 #4
Many thanks to all of you :)

May 17 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3686
by: Christoph Nothdurfter | last post by:
Hallo! I was wondering if my PHP4-Scripts will run under PHP5 (Haeven't tried the beta yet). Does anybody know? Thank you, -Christoph
8
2979
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with speed. They had a vague idea that PHP5 has improved handling of objects over PHP4, so it would probably be faster also. In fact it seems slower. We did a few timing loops, in which a a number of objects were created and and members were...
5
2798
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of Apache - both on port 80 - using different file extensions to distinguish between them? --
11
10578
by: neur0maniak | last post by:
Hi, I've been eager to try out PHP5, so I've dumped it on my little dev machine. It's running WinXP with IIS5. I've put the php-cgi.exe in the "mappings" page as I'm used to doing with PHP4. I've got my php.ini all set in C:\Windows. I created an index.php containing: <?php phpinfo(); ?> When I try to view the page, I get "HTTP 400 - Bad Request".
4
5834
by: badbetty | last post by:
Dear Googlers I have installed PHP5 to run on WinXP against Apache 2. It works! ie. I have tested a few simple scripts and a basic xml document parse. I now want to try the XSL extension so I can transform xml docs. Having copied the php_xsl.dll to a directory where it can be found and done the uncommenting in php.ini, it still will not work. The script I
5
2153
by: Aziz | last post by:
Hi, I've recently contacted technical service of a web hosting company and asked them wheter or not they're gonna upgrade to PHP5 and MySQL5. Here's a quote from their response which confused me a little: "As php5 and mysql5 are still beta versions we don't install beta versions on production servers due to secure reasons, we install only current working versions on production servers"
4
2754
by: Chuck Anderson | last post by:
I am trying to install Php5 on my WindowsXP machine (at home, not on the 'net). I downloaded the Php Windows binary at php.net, unzipped it to c:/Php5, changed my Apache config file to use Php5 with: LoadModule php5_module "c:/Php5/php5apache2.dll" .... and restarted apache (Apache/2.0.55 (Win32) mod_ssl/2.0.55 OpenSSL/0.9.8a) Php5 works fine, but when I execute phpinfo, the registered streams are:
19
2360
by: McKirahan | last post by:
I am working in two environments neither configuration of which I can change; one's my Web host the other a client. My Web host requires the use of the ".php5" extension to use PHP v5.1.4; where ".php" is used for PHP v4.3.11. My client supports PHP v5.2.0 with the ".php" extension. Is there a way to reliably determine if the ".php5" extension must be used on a server? Perhaps via a "phpinfo()" value?
3
3293
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5, only that in old version, I can use $row to access the data in database directly, no need to put double quote around fieldname. BUT in PHP5, this is wrong, I got error message "undefined constant". I know this is because PHP5 see the fieldname...
8
2309
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the constructors work seem to have changed quite a bit and I am not getting the same behavior across the versions. // Some simple code/
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7433
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6223
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.