http://qs321.pair.com?node_id=866364

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am good with Perl but there are many jobs are out there based on LAMP, who needs PHP. Is it worth exploring? From what I have heard in the past that PHP is not a decent language in general. Have you learned PHP? How easy it is to learn with Perl background? Is it something that I should dive into ?

Replies are listed 'Best First'.
Re: Learning PHP
by redgreen (Priest) on Oct 20, 2010 at 18:39 UTC
    http://www.tnx.nl/php.html

    PHP in contrast to perl. A handy page that shows how to map your perl to PHP. This also gives good examples of the inconsistencies in the PHP functions.

Re: Learning PHP
by halfcountplus (Hermit) on Oct 20, 2010 at 18:21 UTC

    As CountZero points out, "LAMP" just refers to a combination of Linux, Apache, MySQL and a web-dev scripting language which will work with them (PHP, Perl, or Python).

    But here's an opinion on PHP anyway, since there could well be many "LAMP" jobs that do require PHP specifically: I had to learn php for a job that required writing a mediawiki extension (since mediawiki is in php). IMO, it is not as nice a language as perl -- regexps are ridiculously awkward by comparison, etc (of course, they are even more awkward in compiled languages). However, I would disagree that "PHP is not a decent language in general". Easy to say, but mostly just ignorance and hyperbole. Such arguments and attitudes are a waste of time, ie, ignore excessive naysayers.*

    PHP borrows most of it's syntax from perl and C++. I found it very easy to pick up. Partially this is because the official PHP online documentation is terrific -- one area I would say the community is clearly light years ahead of "us"; perldoc.org, CPAN, & POD stuff are moldy old scrolls by comparison.

    Also:

    • The more tools in your toolbox the handier you will be.
    • Learning new languages is fun and enlightening.

    Of course, that can lead to the "Jack of all trades, Master of none". But it takes all kinds. Once you get comfortable, the language takes kind of a backseat to the thinkin' and programmin'. I'm happy to be back doing perl stuff, but I'm sure I'll end up doing php work again in the future. $0.02

    * unless they are naysaying MS windows, in which case it is probably all true and worse ;)

      I would also disagree with the statement that "PHP is not a decent language in general."

      I believe that a great deal of the disdain and discontentment with PHP as a language among those who use other languages is that a large number of those who write PHP are by nature less familiar with general programming "best practices." In my experience this has been a result of two factors:

      1. PHP has a rather simple syntax and some great documentation
      2. A large number of PHP developers are "self-taught" (generally because of factor 1)
      That being said, I have worked with a number of those preferring PHP who have extensive knowledge regarding programming concepts in general. Some of these are autodidactic, but most have a formal education and are familiar with more languages than PHP. Formal education tends to engender an ability to abstract language-specific items as well as the capacity to critically evaluate programmatic methods/ways to solve a problem.

      I concur that you will likely find PHP syntax very easy to learn, and would add that there are a great number of features that Perl and PHP have in common.

      Though I prefer Perl I have written a number of projects in PHP, and I would submit to you that learning or coding in PHP need not be detrimental to your knowledge and/or love of Perl. Sometimes paying the bills requires something other than Perl. I believe there are a number of monks frequenting here that often code in other languages. It may be of benefit to you during your time working in PHP (or any other language for that matter) to continue to visit perlmonks and learn from as well as contribute to this community.

      I second halfcount's opinion. It's a breeze if you know perl/C. Instead of hashes, they call them associative arrays, and once you know that, what else do you really need to know? :) PHP is a bit more integrated with HTML/webmindset, which can make some things easier. (I once found a whole php class for making adobe acrobat files in a webbrowser, which I thought was pretty nifty...)

        they call them associative arrays
        That's the influence of AWK showing.

        I came to perl after I could no longer live with the deficiencies of AWK. (Or GAWK, either).

Re: Learning PHP
by CountZero (Bishop) on Oct 20, 2010 at 17:51 UTC
    Funny, I always thought LAMP meant: Linux Apache MySQL and Perl.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Learning PHP
by luis.roca (Deacon) on Oct 20, 2010 at 20:21 UTC

    As an art director and graphic designer I always followed the advice of other professionals I admired who said "Never put anything in your portfolio that you wouldn't want to do every day. Somehow, someway that's what you will most likely be asked to do." It's the same for skills, I never liked working in Flash or Quark so I never stated them on my resume. Do I know how to work and design with them — yes, but I would be miserable working in Flash on animated banner ads for soap every day no matter how much they paid me.

    What's that have to do with php? If you like it, learn it and look for projects that require php. I would strongly suggest that if you're looking to add it to your toolbox because "There's a lot of work out there for it." don't. You'll regret it. Good luck.

    "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." — Don Quixote
      i agree but it's not always that simple. sometimes you need PHP to do 5% of a job, and the rest is LAMP or other. in which case I'd learn PHP even if it's not my thing, so i could get the job that pays the bills. you can't always have the whole cake.
      PHP is pretty old, one of the original languages to add dynamic content to html. it was not very popular until a couple of things happened: a whole lot of extensions (including lots of http and database handling) became bundled in standard PHP, and some people wrote mediawiki and drupal etc, which wikipedia and other high exposure projects exemplified. PHP also only fairly recently became part of standard install for unix and linux variants.
      perl community confusion with the version 5 to version 6 debacle, has also helped PHP proliferate in favor of perl.
      the hardest line to type correctly is: stty erase ^H
Re: Learning PHP
by zentara (Archbishop) on Oct 20, 2010 at 18:32 UTC
    Hi, yeah I feel your pain. Recently, I was exposed to Drupal, the PhP,MySql web content management system. You really had to know PhP. I asked them once, if you could use Perl or Python, and they said no, it was totally web optimized with PhP. I almost felt like I was selling my soul. :-)

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Learning PHP
by Anonymous Monk on Oct 20, 2010 at 17:39 UTC
    You can find some great previous discussions if you search
Re: Learning PHP
by sundialsvc4 (Abbot) on Oct 21, 2010 at 02:19 UTC

    It is relatively easy to learn a new programming tool after your first dozen . . .

    “Skills,” in any programming tool, do not merely consist of understanding the vagaries of the syntax.   Nor can they, realistically, merely consist of knowing how to configure a tool (e.g. Drupal) that some other programmer has designed.   You might find work doing that, but it will be a race to the bottom because there is really no barrier to entry ... and the workplace is stuffed with an over-supply of qualified (sic) people.   There is no “room for one more.”

    I would suggest to you that the entire market for “custom-built web sites” is rapidly disappearing and that it will never return.   PHP is a tool that is adequate for doing that but not good for much more.   You would do well to turn your attention away from the notion of being a “web” developer.   In my opinion, those days are done.

    Languages such as Perl are general-purpose systems that, as such, have considerably more applicability and utility.   Many people who flooded into the programming world in response to “the web” are flooding out of it again, leaving the field somewhat more open to people who can imagine doing things with computers beyond sending database outputs in HTML form to distant web-browsers run by grandmothers.