Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
We don't bite newbies here... much
 
PerlMonks  

Re^7: Perl vs. PHP

by perrin (Chancellor)
on Aug 18, 2004 at 21:43 UTC ( [id://384169]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^6: Perl vs. PHP
in thread Perl vs. PHP

I'm a dilettante too when it comes to PHP, but here's my take on it. You could consider the PHP form of class-naming as equivalent to the Perl form: new MyCompany_Model_ShoppingCart_Persistent in PHP vs. MyCompany::Model::ShoppingCart::Persistent->new() in Perl. In both cases, the name does not actually affect the inheritance, or the visibility of other classes. I consider the Perl one easier to read and organize since the naming implies a directory structure, but that's not such a big deal.

It becomes a bigger deal when you get into non-OO stuff. In Perl, you can do something like this:

package Foo; use LWP::Simple qw(get); my $content = get('http://perlmonks.org/');
This imports the 'get' function into the 'Foo' namespace without trampling functions called 'get' in other namespaces. There is no equivalent to this in PHP because there is only namespace. You would always have to call all class methods by their fully-qualified names. That may not sound annoying until you consider some short and popular function names like try/catch. In Perl, you can define 'try' to mean one thing in one class and another thing in another, but not in PHP. This also means that if you want to override 'exit' in a certain place to do something special, you can do it in Perl but not in PHP.

So, PHP5 classes look like they will help with isolation if you can stick with OO throughout, but are ultimately not as flexible as Perl's namespaces.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://384169]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.