Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
PHP5 lets you say no

The decision to release "PHP5" rather than a "PHP4.4" was taken due to a specific change in the object model - in PHP4 the code
            $second = $first;
would clone an object (duplicate all its contents, whereas in the new model just the reference will be copied, so giving the same object a second name. This change will "break" a few applications that made use of the old (and arguably incorrect) model, and was the incompatability that forced the number change. But with the change in model number, many many other things have been added in as well as "now is a good time to do this".

Many compatible enhancements have been made to PHP4's Object oriented model, and the theme of many of them is to allow the class developer to say NO to the application programmer. From its "Personal Home Pages" origins, PHP has been a trusting language but progressively options have been added to allow for trust to be restricted. The sort of facilities that would have been ludicrous in the early days, but are necessary where a team of programmers (and sometimes a large team) is involved. Amongst the enhancements:

** The ability to label object variables and methods as Private and Protected. (You can use public too, but that's an alternative to the old var label)

** The abiity to mark something final so that it can't be overridden in a subclass.

** The ability to define a class as abstract so that the application programmer can't directly create an instance, and so that the writer of extended classes is forced to provide certain methods.

** The ability to define an interface to that a class can be forced / checked to contain certain methods at compile time.

Other enhancements in the PHP5 model (which do extend the language) include the ability to define a destructor method to be run when an object is no longer required (or at some time thereafter). The descructor method should be called __destruct. You may also name your constructor __construct now, and if you're coding only for PHP5 it's recommended that you do so to prevent the class name appearing within the class. See "Objects in PHP" for links to examples of OO in PHP - both versions 4 and 5.
(written 2005-02-07 03:45:40)

 
Associated topics are indexed under
H108 - Objects in PHP

Back to
The confidence to allow public comments
Previous and next
or
Horse's mouth home
Forward to
Fox and Python
Some other Articles
FAQ - Perl or PHP
Examples - Gadfly, NI Number, and Tcl to C interface
Canteen Dragon
Fox and Python
PHP5 lets you say no
The confidence to allow public comments
Holes in on line information
Searching for numbers
0870 telephone numbers
Tips for the top
2259 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2009: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho