Please create an account to participate in the Slashdot moderation system


Forgot your password?

Going Dynamic with PHP 222

Five-Oh writes to tell us that IBM DeveloperWorks has an interesting article about the OO advantages of PHP V's new features. From the article: "PHP V5's new object-oriented programming features have raised the level of functionality in this popular language significantly. Learn how to use the dynamic features of PHP V5 to create objects that bend to fit your needs."
This discussion has been archived. No new comments can be posted.

Going Dynamic with PHP

Comments Filter:
  • PHP's Comeupance (Score:5, Informative)

    by (1+-sqrt(5))*(2**-1) ( 868173 ) <> on Monday February 20, 2006 @02:08PM (#14762257) Homepage
    I rediscovered PHP last week after a year-long hiatus, and was surpised to find that it approacheth Java in reflection and information hiding; that said, there are some lamentable lacunæ:
    • Class constants must be string literals and only string literals (no variables, arrays or objects).
    • Type-hinting is confined to arrays and objects (feature?).
    The unadorned output of phpDocumentor, PHP's analog to JavaDoc, is also suboptimal; for documenting PHP, therefore, go Doxygen [].
  • Re:PHP 4 V. 5 (Score:3, Informative)

    by drpimp ( 900837 ) on Monday February 20, 2006 @02:19PM (#14762348) Journal
    This page actually has alot of links of changes and new features. What's New []
  • Re:PHP 4 V. 5 (Score:5, Informative)

    by lbft ( 950835 ) on Monday February 20, 2006 @02:23PM (#14762374) Homepage

    There's a good summary on Zend: []

    Basically, PHP 5 adds proper object support (think Java-style) including iterators for objects, and new extensions add good XML support, SOAP, SQLite, better MySQL support (prepared statements, OO interface, etc.)

    I'd recommend reading Adam Trachtenberg's book Upgrading to PHP 5 [] if you're familiar with PHP 4.

  • by cknudsen ( 891397 ) on Monday February 20, 2006 @02:32PM (#14762424) Homepage
    I'd love to take advantage of some of the PHP5 features. However, most hosting services are still stuck on PHP4. How long has it been now? I am the project manager for WebCalendar, and just like during the transition from PHP3 to PHP4, it's going to be some time before we can drop "legacy" support for PHP4 and take advantage of the cool new features of PHP5. So, for now, WebCalendar and other open source apps will have to stick to PHP4.
    FYI.... PHP developer articles updated daily: []
    RSS: rss1 []
  • Re:PHP 4 V. 5 (Score:5, Informative)

    by Foofoobar ( 318279 ) on Monday February 20, 2006 @02:35PM (#14762447)
    PHP5's object are passed via reference by default. Public/Private function and variables in classes are also now supported. The language as a whole has better OOP support and the underlying engine is alot faster as well.

    Also, some deprecated functionallity has finally been dropped. All in all, I've been using PHP5 for awhile now and everything works alot faster as a whole (as I use it with Apache 2 as well).

    One note that might concern you, PHP5 does not come with MySQL built in anymore. You either have to download the update or compile it yourself. It's nice for those who want to use something aside from MySQL and don't want to have to keep it the module loaded constantly but it's also a pain for the beginner hobbyist who has never had to deal with installing the MySQL module for PHP.
  • Re:Experiences (Score:2, Informative)

    by T-Ranger ( 10520 ) <`jeffw' `at' `'> on Monday February 20, 2006 @03:05PM (#14762649) Homepage
    You have the choice of either type hinting OR function overloading. If you use type hinting, you have to pass that function exactly those types (and not a null, either) . And its not realy function overloading; you, as the developer, need to resolve what your being passed. Most everything else that allows overloading, you write multiple functions, and the compiler decides what to do.
  • Re:PHP 4 V. 5 (Score:2, Informative)

    by Anonymous Coward on Monday February 20, 2006 @03:16PM (#14762710)
    For the beginner/hobbyist I found LAMPP, more specifically XAMPP, to be very easy to use. The newest version came with PHP5 and mysql 4.1 (i think). It installs in minutes and works on linux and windows.
  • DB_DataObject (Score:2, Informative)

    by schmidt ( 69858 ) on Monday February 20, 2006 @03:19PM (#14762735) Homepage
    There is an implementation of this idea (and more) in PEAR's DB_DataObject package: dataobject.php []
  • Re:PHP's Comeupance (Score:4, Informative)

    by sweetnjguy29 ( 880256 ) on Monday February 20, 2006 @05:39PM (#14763465) Journal
    Learned a new word: lacunæ (latin for lake) -- in this context, a gap. Well done, sire!
  • Re:Experiences (Score:3, Informative)

    by shmlco ( 594907 ) on Monday February 20, 2006 @05:41PM (#14763469) Homepage
    "At that point function names could be standardized..."

    YES!!!! Not just names, but parameter order as well. Most the functions work one way, but there are just enough that reverse target parameters that you can never be quite sure you got it right.

    PHP: Over a billion functions served... and counting.

  • by Ramses0 ( 63476 ) on Monday February 20, 2006 @06:31PM (#14763781)
    Good web-hosts [] will let you choose between various versions on a per-domain basis. Dreamhost also gives you access to some bits of .htaccess files which I assume you could link *.php4 to the php4 cgi and vice versa for *.php5. Yeah, the cut-rate shared hosters probably don't have the same level of management capabilities, but there are some out there that will let you do some really useful things (ie: ssh access, gcc, svn, cvs, php, ruby, python, mysql, etc, etc, etc). I guess one of their big gaps is with Postgres, I'd be interested if they had some of those management utilities available, but like it or not, most people and projects are MySQL specific.


  • Re:PHP 4 V. 5 (Score:2, Informative)

    by lbft ( 950835 ) on Monday February 20, 2006 @08:18PM (#14764412) Homepage
    With the MySQLi extension (the 'i' stands for improved) you basically call methods on/read properties of a mysqli object rather than passing a resource to procedural functions, get a mysqli_stmt object when you prepare a statement, get a mysqli_result object back from a query, etc. It's clearer and neater than the old way and it opens up opportunities for using some of the newer features like iterators.

    Sorry if it sounded like I meant that it does schema-reading magic and presents your tables to you as objects or something (although I don't doubt that there's code out there somewhere that does it, and it'd be very doable by implementing appropriate _get, _set and _call methods on your particular object. Look at the SOAP extension for an example of that sort of thing.)
  • by cwf0621 ( 948557 ) on Monday February 20, 2006 @09:01PM (#14764602)
    My firm is a fairly big fan of WASP ( []). Check it out.
  • Re:PHP's Comeupance (Score:3, Informative)

    by stonecypher ( 118140 ) <> on Tuesday February 21, 2006 @02:25PM (#14769544) Homepage Journal
    Well as long as you bring up grammar:
    1. Sir is not capitalized. This miscreant tendency is American ignorance of the proper title Sir as given during knighthood by royalty. You may call Sir Edmund Hillary with the capitalized Sir. Given your obvious deep familiarity with the 19th century, perhaps I should also refer to Sir Mick Jagger. Some random person on Slashdot most likely has not attained such a title.
    2. "is it informative" - you've got a typo, and informative is not a proper noun, even when cataloguing moderator points.
    3. As an aside, please don't refer to something as informative unless you know privately. As I display in another reply, in fact the parent post to which you refer is bunk.
    4. To debase is to make immoral, not to water down with ill speech.
    5. To draft is to draw, sketch, or make a crude preliminary version of something. Whereas speech can be drafted, unless this is a particularly subtle insult - which your usage of language suggests that it is in fact not - then what you are looking at is a final copy, not a draft. Even email programs get this one correct.
    6. Queen's English is posessive.
    7. It's called the King's English []. The Queen's English is a reference to specifically Queen Victoria, and was a temporary tipping of the hat to the first gynarch generally recognized by Britons. We do not continue to tip our hat to her.
    8. It's hard to tell whether a reference to proper English, immediately followed by the appalling "Internetland," is intentionally tongue in cheek. As a rule of thumb, if people aren't sure whether you're joking, then your joke has failed.
    9. To obtain is to take something which someone else had had previously. Given that frist psot!!1!eleven is not something which can be stolen away from someone else, to use obtain in this fashion is ill.
    10. To covet is to desire or lust for something sexually; it comes through Old High French's "covitiere," thence from Latin's "cupidere," the cherub of Eros. If you covet first post, seek help.
    11. Furthermore appropriately follows further. You've gone from first to third. Further, it makes you look stupid. Furthermore, it should be stated in the fashion I've just given.
    12. Epistles are letters sent by clergy as regards scriptural canon. Even were you the Pope of Grammar, which you are not, this would be incorrect.
    13. "So to speak" is the verbal equivalent of the better-recognized editorial "[sic]." It indicates specifically that you are repeating what someone else has said verbatim, despite being aware of language errors of some or another form. Hence, if I were to say that you had said "pole position of posters, so to speak," so to speak, I would refer to your inane use of the phrase "so to speak."
    14. Congratulation is singular. To refer to congratulations is to refer to a group of such statements, or to such a statement given to a group as a set of individual congratulatory statements. That said, I do applaud your use of the contextually accurate accolade, and hereby give you congratulation therefore.
    15. A toast, in the context of wine, is a speech. You cannot drink a speech.
    16. One drinks for you, not to you.
    17. It is common misconception that the word concieve may be used to refer to impregnation. To concieve a child is to begin to attempt impregnation. Many people who concieve a child never have children, and in most cases time is taken between conception and impregnation.
    18. Correspondance is the third or latter piece of a private exchange between a small group. This is an edict, if anything.
    19. You wish that something should, not that it shall. Shall is affirmative. The sun shall continue to rise. Something which is indefinate should continue. Murder should remain illegal. Wishing for something definate is silly.
    20. The idea that a correspondance would be eternal is a bit chee

Loose bits sink chips.