Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
PHP Programming

Is PHP Still a Worthwhile Language To Learn? (stitcher.io) 137

mbadolato (Slashdot reader #105,588) shares this post from Belgium-based programmer Brent Roose: It's no secret among web developers and programmers in general: PHP doesn't have the best reputation. Despite still being one of the most used languages to build web applications; over the years PHP has managed to get itself a reputation of messy codebases, inexperienced developers, insecure code, an inconsistent core library, and what not. While many of the arguments against PHP still stand today, there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP.

In this post, I want to look at this bright side of PHP development. I want to show you that, despite its many shortcomings, PHP is a worthwhile language to learn. I want you to know that the PHP 5 era is coming to an end. That, if you want to, you can write modern and clean PHP code, and leave behind much of the mess it was 10 years ago.

The article notes PHP's opt-in type system and performance-enhancing rewrites (including the ability to store compiled chunks of PHP code in memory). And it argues that PHP "is still evolving today," with a package repository averaging over 25 million downloads a day. There's also PHP web application frameworks (as well as asynchronous frameworks), so "PHP isn't just WordPress anymore."

And in keeping with the core team's yearly release cycle, PHP 8 is expected at the end of 2020, which will include a JIT compiler, "allowing PHP to enter new areas besides web development..."
This discussion has been archived. No new comments can be posted.

Is PHP Still a Worthwhile Language To Learn?

Comments Filter:
  • Short Answer, no (Score:2, Insightful)

    by TheSimkin ( 639033 )
    Long answer, also no.
    • by Z00L00K ( 682162 )

      I agree, unfortunately a lot of various solutions have been made using PHP.

      It's of course simple to say it was wrong to use it, but it's the same with many script languages that results in obscure files where three languages effectively co-exist, in this case PHP, HTML and JavaScript - with a lot of bugs and security holes as a result - even worse you could also have some SQL in it too for "good measure".

    • by UID30 ( 176734 )
      This. 1000 times this.
    • I know. Quit asking.

    • by Jamu ( 852752 )
      Longer answer: It's never been worthwhile to learn.
    • Comment removed based on user account deletion
      • by ShanghaiBill ( 739463 ) on Sunday January 26, 2020 @07:20PM (#59658760)

        I would advise everyone to learn it, just not as their first language

        PHP should be learned on an "as needed" basis.

        If you don't need it, don't learn it. When you do need it, learn just enough to fix the current problem.

        Many languages teach you new principles and perspectives. Even horrible languages like JavaScript have good parts [reddit.com]. But PHP isn't like that. It was a quick hack without any underlying design philosophy, and then more and more hacks were inconsistently glommed onto it. You don't learn and grow by studying something like PHP.

      • by PCM2 ( 4486 )

        It's worthwhile if, say, your job requires you to hack on WordPress.

      • I find PHP absurdly easy to use, mainly because of the documentation. Yes it's a nasty language. Fingers crossed the WebAssembly has garbage collection, thread support, and DOM access, in the next 10 years. Because once that happens, we'll be using whatever language we want.
      • I disagree. It sucks, it's a terrible language, but:

        (1) it's one of the most popular languages in existence and probably the most popular for back-end web work, and as a result if you want a fucking job you better learn this shit, and

        (2) it has enough gotchas (because it's awful) that it's a language that you have to learn. It doesn't take very long to learn it, but you can't just go in and say "I know Javascript, this is JS with dollar signs and explicit classes". As an example, you have to find out, extremely early, why you rarely use the '==' operator, and likewise switch() and some other statements for similar reasons.

        I would advise everyone to learn it, just not as their first language, as, like BASIC in the 1980s, it'll set you back if that happens.

        Basic was the first language I learnt. And it didn't set me back. It made me learn assembly, and since then, when learning a new highler leve language I always understand what is happening underneath.

  • by Aighearach ( 97333 ) on Sunday January 26, 2020 @03:05PM (#59658224)

    Do you have an irrational dislike for programmers, and assume that if you were a programmer you'd be better than all of them, but you're wise enough not to want to learn about any of that stuff?
    But now you need to write a dynamic web application?

    If yes, learn PHP.

    If no, learn any other web language.

  • by Rosco P. Coltrane ( 209368 ) on Sunday January 26, 2020 @03:05PM (#59658226)

    there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP

    You can right clean and maintainable code in any language. That doesn't make the language suitable for the job or desirable.

    Quite frankly, PHP needs to die. But considering how much of it is deployed out there, it is definitely a worthwhile language to learn, just for job security. I learned COBOL decades ago for that very reason and I still make decent money with it to this day, although the language is hateful and totally deprecated.

    • by AmiMoJo ( 196126 )

      PHP strongly resists writing clean and maintainable code. Maybe it is possible for small projects, but not for anything significant.

      These days there are much better languages for this task and if you see a job advertising for PHP it's probably a good indication that you will be stuck in hell dealing with the worst legacy code base imaginable and should run a mile if you can.

      • by jrumney ( 197329 ) on Sunday January 26, 2020 @04:56PM (#59658474)

        If you use a decent framework, you can write clean maintainable and even secure code in PHP. Most of the jobs want experience with the frameworks rather than the language these days. Learning a bit of PHP to throw together a dynamic web page is easy. Mastering Laravel so you can develop a scalable data-driven front end for a major client is another thing altogether.

      • All programming is based on writing clean, maintainable code.

        If you can't write clean, maintainable code, YOU SHOULDN'T BE A PROGRAMMER.

        If you have to pick a development environment to compensate for your basic inadequacies, that's not everybody else's problem!

        • Re: (Score:2, Insightful)

          by Anonymous Coward

          All programming is based on writing clean, maintainable code.

          All programming is based on getting whatever you are paid to do done.

          If you can't write clean, maintainable code, YOU SHOULDN'T BE A PROGRAMMER.

          Everyone thinks their shit doesn't stink... more at 11.

        • by dwpro ( 520418 )
          That's easy to say, but languages often impose specific patterns that aren't clean, and development environments do matter (can I debug without console.write() statements? Batch renaming? How about testing changing a variable on the fly?) Saying 'write better code' as though that answers whether or not certain languages and environments have clear advantages is hardly helpful.
    • there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP

      You can right clean and maintainable code in any language. That doesn't make the language suitable for the job or desirable.

      Quite frankly, PHP needs to die. But considering how much of it is deployed out there, it is definitely a worthwhile language to learn, just for job security. I learned COBOL decades ago for that very reason and I still make decent money with it to this day, although the language is hateful and totally deprecated.

      This so much. But there's more because the kind of people who write in PHP are often (not always) the kind of people who hate software. People who choose PHP simply because that can get them a well paid job and so really don't take a pride in their work. Having watched PHP code at a few companies and seen that it seems to get worse and worse at a higher rate than other languages, this is the explanation I have come to. People who don't care choose PHP which means that people who choose PHP mostly don't

  • by hasanen ( 745497 ) on Sunday January 26, 2020 @03:20PM (#59658266) Homepage
    I am still making good money from writing good PHP code. I was about to trade it for something else till I found Laravel which is making PHP saner and more convenient. One thing I love(d) about PHP, is the code/functions style is as messy as legacy C code. People coming from C background will find their same function names in PHP and working on the web.
    • Re: (Score:2, Interesting)

      by Anonymous Coward
      I make a small fortune supporting old Delphi apps that companies are too cheap/scared to update. Being proficient in an obsolete technology isn't very useful, but it sure is profitable when you can bill out custom work at $500 and hour. Not a lot of guys running around who know object pascal these days.
  • Framework design/choice makes a far bigger difference than the app language. All mature languages have ugly sides, and you just learn your way around them.

    That being said, it's a fad-driven industry and if you pick the wrong trend/fad, you can get screwed career-wise; so I can understand why one would be hesitant to avoid anything with a "Legacy" stamp on it. Python is currently the "in" language, for good or bad.

    I do wish PHP would add optional named parameters, though. C# got me addicted to those.

    • PhpStorm (arguably the best PHP IDE) offers optional "fantom" named parameters, where it would show a faint grey parameter name automatically on all function/method calls. The benefit is that it won't affect the actual source for those who prefer to not have it. Other (freeware) tools may have the same too, I didn't quite check.
    • PHP does have optional named parameters though. Not sure if it has since the beginning, but definitely since version 5 at least.

    • And all a framework does is enforce good coding standards/structure/architecture anyway, and it makes it relatively easy to do so since it is doing all of that for you.

      Without a framework or template engine, etc. it is still easy to write good PHP code, and organize a project well. Just takes a lot of discipline. And using 7.x and doing the proper thing with database queries (prepared/parameterized statements) , etc. And not mixing back end code and front end code and mixing markup and code output and su

    • The reason it's a fad driven industry is because most people don't evaluate new technologies, they just switch to them when everyone else does.

  • Yes (Score:4, Interesting)

    by JustAnotherOldGuy ( 4145623 ) on Sunday January 26, 2020 @03:49PM (#59658324) Journal

    Yes, it certainly is. PHP has made me a ton of money. Paid off my homes, cars, and almost everything else for the last dozen years or so. Vacations, toys, etc etc etc.

    But hey, I'm unfairly biased because I tend to approve of things that make me a ton of money.

    If I was just starting out, I'd probably learn Python, but PHP is still extremely useful.

    • by malkavian ( 9512 )

      Good job it's not an either or world. :) Best idea is to learn something reasonably well, then add it to a toolbox, and use the right tool for the right job in the right place. :)

    • I wrote a PHP app that sold for over $7M to a major corporation.

      • I wrote a PHP app that sold for over $7M to a major corporation.

        Standby for incoming haters... jealous incoming haters. They'll spend their time telling you how bad PHP is while we're busy printing money with it.

        For example, I'm literally sitting in a nice house in a nice neighborhood that was paid for by little ol' me writing PHP here at home in my office, and I own a 2nd house in another country that was also paid for by writing in this terrible, terrible language. Curse you, PHP!!

        So yeah, someone please tell me again how awful PHP is, because I can't see it from here

        • by Pascoea ( 968200 )
          A carpenter will argue with another carpenter till they are both blue in the face about what kind of hammer is best. Then when they are done, they'll both go back to building houses with their hammers. Point being? Use the tool that works for you.
          • A carpenter will argue with another carpenter till they are both blue in the face about what kind of hammer is best. Then when they are done, they'll both go back to building houses with their hammers. Point being? Use the tool that works for you.

            I'd say "use the tool that's right for the job, not for you."

            You don't want to use a Roofing Hammer for framing, and you don't want to use a Dead Blow Hammer for blacksmithing.

            • by Pascoea ( 968200 )

              I'd say "use the tool that's right for the job, not for you."

              You don't want to use a Roofing Hammer for framing, and you don't want to use a Dead Blow Hammer for blacksmithing.

              Absolutely fair point. I was more referring to the different sizes, weights, handle type, face type, material, quality, etc of framing hammers that area available.

              • Absolutely fair point. I was more referring to the different sizes, weights, handle type, face type, material, quality, etc of framing hammers that area available.

                Everyone knows that the Husky 22 oz. Milled Steel Framing Hammer is the only one that true patriots use.

                The founding fathers all used it, which is why they're called "the framers of the constitution". A lot of people don't know that.

                • by Pascoea ( 968200 )
                  I actually had to google for the varieties of framing hammers. I need to upgrade. Forged titanium with a steel/fiberglass handle, 10oz and can hit like a 20? Sign me up.
  • Of course! (Score:4, Informative)

    by edibobb ( 113989 ) on Sunday January 26, 2020 @03:56PM (#59658336) Homepage
    Any language is worth learning, just to see how it works if nothing else. However, I would not use PHP for a new project unless there was an overriding reason.
    • Very much agreed. I learned PHP back in the 90's since it was a fast and easy way to get a database backed website up and running. I've moved to python since then, but I'd expect after 20+ years of improvement PHP is still really good at it's core abilities.

      That and once you learn the fundamentals of programming with PHP, you can take those skills to your next language.

      I'd suggest if you aren't learning a new language every 5 yrs then you may be limiting your potential.

  • No, it is not (Score:4, Interesting)

    by Hadlock ( 143607 ) on Sunday January 26, 2020 @04:01PM (#59658348) Homepage Journal

    Just like saying you worked in QA at one point in the past is carreer suicide, so is saying you've ever worked with PHP
     
    PHP is (probably) a great gateway programming language, but it's not valuable for your career compared to something like Python, and you can find good paying jobs with growth companies using it.
     
    Most companies hiring for PHP developers are not growth companies and PHP jobs pay average at best

  • by bjdevil66 ( 583941 ) on Sunday January 26, 2020 @04:09PM (#59658374)

    In short, yeah. It's a good enough language to learn because it has real value. If if didn't, PHP wouldn't have outlasted other languages like Perl, Ruby, etc.

    Yes - It is true that if you've thrown together "Howl's Moving Castle" platter of procedural PHP spagetti, driven by feature creep while missing sound architecture design and a long-term plan for support, etc. PHP will hate you and your family.

    Yes - It is true that if you have to pick up a Drupal/Wordpress mess that someone previously cobbled together with no relevant CMS experience - other than cobbling together Stack Exchange answers, PHP will hurt even more.

    But if you hire an experienced developer (ideally one that uses a reliable, supported PHP framework and knows PHP 7.2+), then PHP the language will not let you down.

    Just like Javascript - a widely reviled, mocked language than PHP until recently - PHP just has to be wielded by the right hands.

    The language has matured. PHP developers just need to follow suit.

    (I don't know about the JIT compiler feature. That sounds like shoehorning PHP into a use case it wasn't really designed for, where it will be competing with superior solutions...

    • by jemmyw ( 624065 )
      Ruby is still going strong. It might no longer have the hype, but the jobs and community is still there. It might not be my language of first choice, but to throw together a prototype web app quickly and cleanly Rails still has the edge.

      PHP always needed a JIT like caching accelerator to make its performance acceptable. I recall needing to use one in 2007.

      I loathed PHP in those days. The consultancy I was working for started pitching Drupal as a CMS and so inevitably they started asking me to write plugins
    • It's a good enough language to learn because it has real value.

      I entirely agree. PHP is a fine language for the job it performs. The quality of written PHP code is directly proportional to the quality of the programmer writing it. I find that PHP is most reviled by the same type of low-quality programmers who think that their poor performance can be blamed on their tools.

    • PHP stands for "Personal Home Page". It is a shit language that exists solely for doing web pages. People force it to do other things but that is really what it is for and it sucks.

      PERL and Ruby are general purpose scripting languages. PERL is an incredible text processing language that can do damned near anything. Ruby is used in Chef. Python, which I despise (it has significant white space which is literally moronic) , has taken over a lot of the use cases for PERL and Ruby.
      • by raynet ( 51803 )

        I have plenty of scripts on my linux servers that have been written in PHP. They work just fine and writing them is usually much faster and easier than in Perl, Ruby or Python.

  • by nagora ( 177841 ) on Sunday January 26, 2020 @04:22PM (#59658396)

    If they're not, then no.

    I get paid a load of money to program in PHP and that's handy because it would take a lot of money to make me program in PHP.

  • Unless you are completely the master of your own domain... if you want to get paid for your time versus hobby programming or FOSS project volunteering - the languages you'll need to use are going to be at least partially driven by the choices made by others. You're not going to walk into a job and have the latitude to choose what you'll be writing your code in, nor what platforms are being used.

    While I don't particularly like the language, if you need to do more than trivial support for any popular web CMS

  • For anyone using Laravel (which uses substantial parts of the Symfony framework) the answer is undoubtedly yes. I have an easy to install, excellently documented framework with lots of features out of the box. It's on par with Rails (largely because founder Taylor Otwell takes the Rails as part inspiration).

    Package management: Composer packages through packagist are readily available. All of AWS covered, most major SaaS companies (HubSpot, Pipedrive etc) have SDKs for PHP. Admittedly some packages are of po

  • I have used PHP since 1997, where appropriate (web middleware) or easy (scripting). Python is slower and you can do anything with it that PHP does, with a standard set of idioms. Now that I can spin up 10 machines, that's not such a bad tradeoff. Reading PHP now is a lot like reading Java and that's the fault of The PHP Development Team. Like JS, they are SLOWLY morphing the language into something to gain traction outside of their niche, as if breaking backward compatibility over time will give PHP the bes

  • I developped some great stuff with it, and it still does the job. But the new kids don't care about it, and they don't teach it in school. Now when you apply for a job and you mention PHP, the recruiter doesn't know what you're talking about. But I repeat it's still a great platform.
  • In the last year I have written two data driven RESTful APIs using PHP, replaced a NodeJS project with PHP, built a RESTful API using Python, and maintained a mess of Matlab/Visual Basic (soon to be replaced with Python). PHP is easy to work with provided you don't have preconceptions of what a language should be. It is both a world class language that a subset of developers love to work with and a vocal sub set of developers love to poo poo. It is in some ways a throwback to the days of C. In other ways it
  • by ikhider ( 2837593 ) on Sunday January 26, 2020 @06:52PM (#59658704)
    If you were building a website with dynamic content and it needed to interact with a database, like say, MariaDB, but did not want the website to be too complex, what would you use instead? (Also) say you were building from scratch because you want to break the CMS dependency on the likes of Wordpress, Drupal, Joomla or whatever and have things look exactly how you want, what simpler way than HTML5, CSS3, MariaDB and PHP? What if you want to include things like a contact form? Especially if you are a (relative) novice. So far, documentation the PHP and MaraiDB route is pretty darn good. Lots of books and video tutorials to show you how.
    • by tepples ( 727027 )

      what simpler way than HTML5, CSS3, MariaDB and PHP?

      HTML5, CSS3, PostgreSQL or MariaDB or SQLite, and Python.

      Python is not venomous. Python gives hugs.

      • Documentation? Say I want to build a blog from scratch (humor me) where are the tutorials for this?
        • You wouldn't really want to build something up "from scratch" but using one of the many Python webapp frameworks makes it easy. Django is popular, though I don't use it myself, and if you're curious here's a tutorial showing how to make a very barebones blog app off Django in python: https://djangocentral.com/buil... [djangocentral.com]

          Flask is another popular framework, although does far less than Django, but I like it for what it does. It's lightyears better than working in PHP in my experience. Python generally just makes

          • Perhaps it is telling if a language does not allow you to build from scratch or it is too complicated. That is why I am not fond of CMS, if you want to tweak something 'just so', you really need strong underlying knowledge. So you may as well learn from scratch to get at that bit you want anyway. I'll stick with what the well documented, tried and true and get to python later. I picked up a couple of books on Python and realize it is a bit of a journey and am already pretty far along the PHP route. Not to d
  • Anyone can write crap code with any given language.

  • WTF? (Score:4, Insightful)

    by humankind ( 704050 ) on Sunday January 26, 2020 @08:23PM (#59658910) Journal

    Is the most popular and most used scripting language on the Internet worth learning?

    What the fuck, are you a fucking moron?

    90+% of the Internet is running on PHP.

    Yea, listen to the fucking idiots here who say no. Also, buy Bitcoin.

  • There are many tools to master.

  • by Sigma 7 ( 266129 ) on Sunday January 26, 2020 @11:45PM (#59659424)

    Is PHP Still a Worthwhile Language To Learn?

    If you're going to ask a such a leading question with the answer of "no", at least provide an alternative that's superior in every respect (including ease of programming, popularity, and so on). Until then, programmers have to churn through learning every single programming language in hopes that one of them is in demand.

    Instead of burning energy on making these questions, they could instead be focused on making tools for better programmers and their practices- make it easy to write and debug code, not worry about fiddling with compiler settings, update the documentation that explains replacement for deprecated functions, etc. Software development is paraded as a profession - lets treat it as such rather than keeping it like ad-hoc alchemy.

    And unlike the OP, I'll make a recommendation myself: INTERCAL.

  • by Qbertino ( 265505 ) <moiraNO@SPAMmodparlor.com> on Monday January 27, 2020 @12:28AM (#59659502)

    Disclaimer : I do PHP and WordPress for a living. A good living. And I get to leave work at 17:00.

    PHP is a language that shows how domain specific languages look like when they do their job well. PHP makes the server side Web trivially easy compared to anything else out there.

    It goes something like this :

    - No memory leaks. Only the occasional timeout.

    - Stateless? Nope. You can have all the state you want. But only for 3 minutes.

    - Check out our awesome integrated deployment process: Copy. Paste. Done.

    - 3000 projects on one host. 0% CPU load.

    - We run bad code really really well. IWhat do you think made WordPress so successful?

    My time to market for any project is roughly 10 days. And that's because marketing takes 3 days to agree on their logo. In a nutshell: PHP - Getting the job done since 1994.

    Welcome to the club.

  • PHP while widely hated is not dying anytime soon. It is still pretty much everywhere, just think Wordpress, and with a good linter it is not so bad. It is not your average 200X years PHP, it has good libraries and many of its quirks have been smoothed out or linted out.
    What is not so good is that PHP devs are everywhere and AFAIK, the pay is not so great. But I guess that a good PHP dev with up to date skills can probably make his/her own money.
  • This is like asking somebody who never drinks: Do you still drink a bottle of booze a day, or did you stop?

    As somebody who had the "pleasure" of professionally coding PHP for five years:
    The languge is a joke. Worse than JavaScript. All language parsing rules seem to be tacked on ad-hoc. I remember writing lines of code, then a line with a random word, then more code ... and it would work!! Because any unknown identifier is interpreted as a string literal (WTF#1) and any expression with a return value that i

    • by raynet ( 51803 )

      I would never code life support machine using libraries, that just isn't a safe way to write code that absolutely cannot fail.

  • Absolutely not as a first or beginning language. PHP is like the English of spoken languages. A mishmash of bowwktings, inconsistencies, and quirks. I did it for years and I still needed the manual on hand to double check if a function name I needed had underscores or not, or if the one I wanted was literally the "real" one to use
  • When something is as successful as PHP, but purists say that it's garbage, the reasonable conclusion to draw is that there is something about it that the purists are not seeing.
  • PHP was never a worthwhile language.
  • People point to Facebook and Wikipedia. These projects are successful *IN SPITE OF PHP* not because of PHP. If you ever have a choice, why the fuck would you choose a piece of shit language like PHP when you have Python or Go?
  • The great thing about PHP is you can write absolute garbage code, and it'll still run.

    The bad thing about PHP is you can write absolute garbage code, and it'll still run.

  • Don't waste your time learning legacy stuff unless you have taken a job supporting a legacy app. Otherwise you are spending time that would be way more beneficial to be spend on modern patterns.
  • I'm not necessarily going to try to become proficient at it, but I think I should at least be familiar with it.

    Just now I started out with PHP Tutorial [w3schools.com]. (Your basic "Hell! Oh, World." lesson).

    I'm mostly a C person. PHP is something I've only glanced at before. So I did the first exercise and then took the quiz [w3schools.com]

    I admit I was blindly guessing at a lot of them, but despite all the horrible things I've heard about PHP I decided to guess the way that I thought made the most sense for some of the ones I truly

Prediction is very difficult, especially of the future. - Niels Bohr

Working...