To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Upgrading PHP

Upgrading PHP Issues concerning PHP version upgrades and future releases

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-24-2004, 02:27 PM   #1
access9
Member
 
Join Date: Aug 2002
Posts: 88
Overloadable constructors?

Having the ability to overload a constructor would be so hot! Does it have it?

Also, in the Changes in the PHP 5 / Zend Engine 2.0 page, it talks about overloadable method calls. It says
Quote:
Both method calls and property accesses can be overloaded via the __call(), __get() and __set() methods
How is that overloading? The example doesn't even address overloaded methods or constructors.

Why would they use __construct() instead of the name of the class like in PHP 4 (or Java/.NET/C++)?

-a9
access9 is offline   Reply With Quote
Old 06-25-2004, 02:55 AM   #2
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,124
No. Having different constructors with different signatured would be tricky to do in a loosely-typed language like PHP. does new Foo($bar) refer to Foo's constructor __construct($integer_parameter) or the constructor __construct($string_parameter)?

__get() and __set() are used to alter the behaviour when you use $foo = $object; or $object = $foo respectively (where $object is the object with the __get() and __set() methods). It's overloading assignment. $object->__call('wibble') is called whenever $object->wibble() is used in the code (whether or not $object has a method called wibble()). You're free to write any code you want in __get(), __set(), and __call(). You could, for example, perform different tasks depending on the types of the arguments passed to those methods.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 05:37 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.