Anyone here have any experience with PHP? I've never really used it myself and don't really want to, but I do look at things like http://phpsadness.com/ from time to time.

These complaints range from "fairly minor" (some stuff like function names/args and some syntsx complaints) to "how is this language even used" (segfaults in a scripting language, broken things like "create_function", comparisons and ternanry operator).

Of course, i don't program in PHP so i don't know how bad any of this actually is.

Anyone actually use PHP or did use it previously?

  • 5
    “Any one use PHP” oh about 90% of the internet lol
  • 2
    like all languages:
    You can write something beautiful - say, "clans of the alphane moon", or really funny, like "Eric", T. prachett.
    Or some really horrible shit, like propaganda, or current news articles.

    PHP is the same. It has shit code, and good code. it all depends on the writer. People like to bash it (not that Bash is any better) more then others.

    But don't get me started on JavaScript.
  • 2
    @ScribeOfGoD I wonder how true that is if we removed WordPress from the equation
  • 6
    Despite the apologetics of the "all languages are beautiful" people, there is no denying php has historically been a mess of a language due to not having any cohesive design philosophy behind it. And I say that as someone who works with it regularly and loves doing so.

    That said, they've improved drastically over the past several years and it's becoming much more stable, consistent, and modern in its design.
  • 3
    Yes, it's a sad language.

    Yes, it's possible to recreate all these issues,

    Yes, you literally have to know what you are doing to create most of these issues.

    Yes, function names and args are in weird places at times, but you get used to it or write a utils class to put a wrapper over them and create your own consistency.

    Yes, PHP is an overly abused language, but that's because it has a low entry barrier for server side, and wordpress abusers think they know how to code.

    Yes, I'm sure if you sat next to someone with a decade or 2 experience in the language almost all these issues go away.

    A lot of the issues in php sadness I'm yet to stumble upon accidentally.

    People love to bitch about http://phpsadness.com/sad/1
    But show me a single dev who uses '::' outside of a static class on purpose.
  • 1
    You could highlight the positive things instead.

    PHP FIG for example.

    Coding standards and framework interoperation instead of NIH.

    I've been involved with PHP for over a decade and in my opinion you can hate a lot of PHP (even in newer versions) - but they're constantly improving and turned around from a pretty toxic community / internal development to a more friendly and collaborative system.

    What most people miss - and this is true for any language - is that there is more than pages like ShitOverflow.

    I always love to read Planet PHP now and then despite not having much contact now adays with it.

    Many authors of PHP have - especially because PHP has such a toxic background - a very broad knowledge on how to solve things better. Most of these solutions are easily transferable to any other language - because PHP isn't as backward as many make it seem.

    It has a lot of dark corners, no discussion needed - but looking back like PHP 4 to now it's like a Phoenix from the ashes.
  • 2
    Now let's educate you:






    Never, and I mean NEVER use https://www.phpmyadmin.net/ , or in the odd case you do use it, NEVER have it accessible to the public internet.

    If you're using PHP 3, 4, 5 or 7 to start a new project, you already made a mistake.

    If you see mysql_* extensions, you are on php 5 and should move to a new tutorial.

    If unsure of a function and it's from php, then look it up at https://www.php.net/index.php

    Just stick clear of the comments, sometimes there more about abusing a function then actually giving a decent idea on how it works.
  • 2
    @ScribeOfGoD Yeah no. That statistics refers to "90% of tracked websites where a bot can easily detect the technology it's written in" (and btw, it's down to 77%). Take devrant.com - https://w3techs.com/sites/info/... has no idea the site is built with PHP, because devs followed some decent development practices, which are standard in pretty much any other programming language but PHP. The same way authors of that statistics can't tell that DevRant uses PHP, they can't tell what languages most sites use unless they either use some known platform or don't follow good development practices.

    So really, the message should be that "77% of websites based on either a well-known platform or made by shitty devs use PHP". Which is far less impressive, but does highlight why so many people hate PHP.
  • 2
    @hitko no one uses w3 and expects an accurate answer 😅

    DevRant doesn't even identify as using PHP through the headers so 🤷‍♂️
    There's a php api, but I've got a feeling the client side is static for the home page.

    >> GET / HTTP/1.1
    >> Host: devrant.com
    >> Accept: */*
    -- Mark bundle as not supporting multiuse
    HTTP/1.1 200 OK
    Server: nginx/1.10.3 (Ubuntu)
    Date: Sun, 03 Apr 2022 21:54:41 GMT
    Content-Type: text/html; charset=UTF-8
    Content-Length: 31650
    Connection: keep-alive
    Vary: Accept-Encoding
  • 1
    @C0D4 There's a list of technologies used by DevRant on the "About" page, and iirc @dfox confirmed that it's in PHP. Also the home page varies depending on whether you're logged in or on mobile, so it's definitely not static. DevRant just doesn't expose any unnecessary info or those ugly "/login.php" urls, and as long as you do that, it's pretty much impossible to tell what server-side language your site uses.

    W3techs are the source of almost every single web usage / technology / ... statistics, and most other sources just get their data from them, they only vary in how they process the data (e.g. w3techs only include top 10M websites, but other sources might include more websites or weigh them based on traffic or something).

    Anyway, it doesn't change the point that those statistics only include what they can measure, and PHP is by far the easiest to measure due to the prevalence of bad practices and shitty devs.
  • 5
    ... I know I'm a bad person,.but backend and bad language...

    JavaScript? I mean it's like.... Stuff for generations of nightmares.

    Perl? I'm not joking. These things exist. Never was a fan of perl, seems like it self destroyed the last years.

    Ruby? No experience at all. But if PHP is mentioned due to devs producing craptastic apocalyptic nightmare stuff, reading @Root s rants definitely shows what amazing pile of crap you can achieve if you use a language to abuse it (that's my gist of roots rants, might be wrong ;) )

    Python? Python can be very fun and a great go for APIs, most if you use ASGI / ASYNC. But if you've ever seen a homegrown python 2 "we just threw randomly everything via PIP in and then made it somehow runnable via CGI".... You know what the Gordian Knot looks like. Sadly you can't cut it because you don't even know what to cut. *sigh*
    Transitive dependencies everywhere.

    I have no experience with Go. Heard some good things. Some bad things. Not sure.

    JSP anyone? Fucking a hornets nest while on Viagra. Same for ASP and other stuff.


    In most languages it really is the age of a project that shows.

    I've had few projects who were alive for more than 15 years.

    PHP 3 - PHP 4 mig - PHP 5 - PHP 7

    From times of IE 5 to Edge.

    Exploring these projects is always a funny task.

    Somehow like a mixture of profiling who the most brutal psychopathic serial killer is vs how many different idioms of programming you find.

    Back in the 90s most of us didn't really knew what was coming, we were just like do this and be done. (and many of us didn't really knew what we were doing, as we're talking about a total different internet then and a complete different mindset at that time).

    And this has changed a lot...

    I guess that's why I like to animate people to reflect on the history of technology, IT and languages. In 30 years plus so much has changed that it's hard to keep track of it.
  • 0
    I forgot to add.

    if I ever see someone commit alternative syntax in php, I'll burn them alive.


    This ^^ right here is exactly what you don't do in php and live to tell the tale.

    But otherwise, it's a great language to get into, it's paid for my life as it is and I have little regrets with that 😅
  • 0
    The latest versions of PHP would look almost acceptable, but PHP devs have this nasty habit of loving the worst tools possible.

    The language you're using was already horrible to begin with, there was really no need to make the situation worse and adding Laravel on top of it.
  • 0
    @IHateForALiving wonder what you think of cakephp if you have a problem with Laravel lol
  • 0
    Three things to consider:

    1. Doctrine is *the* ORM in PHP. Doctrine is a collective clusterfuck of multiple DB-related projects. It is slow and (compared to other languages) has not a lot of features. Do you want to map Value Objects? Sorry, but Doctrine Embeddables seem like the right choice, but they just suck. Oh, and they will be removed in Doctrine 3.
    You are better off hydrating and deflating by hand... welcome to 1999.

    2. Composer is *the* packet manager for PHP. Unfortunately, you cannot have two different versions of the same library at the same time. That is also true for the dependencies of your dependencies. That's right: ALL dependencies must be compatible with the same (minor) version of one another!

    3. Arrays (hashmaps) are *the* preferred choice for anything PHP. The community, including every big framework, is obsessed with arrays. Why not use a DTO with IDE auto completion and some documentation? No, multi-level arrays everywhere. Use the docs to guess the keys.
  • 0
    Oh, and one more thing: Composer, PHPUnit and Xdebug are community projects. PHP does not have its own packet manager, testing framework or debugger.
  • 0

    What Composer does is sane. Multiple versions of the same library is _insane_.

    Regarding the rest - Doctrine is fine. They kept for backwards compatibility a long time the API as is - I guess with 3 many changes will come as they broke it.

    You can pretty easily convert DTOs to arrays.
  • 0

    Well, the thing about multiple versions of the same library is: if I want to use psr/log v3, I don't care If another library I'm using requires psr/log v2.

    Why should I care about the dependencies of my dependencies? The only dependency should be the PHP version (+ php-extensions).

    "php-scoper" does a clever trick by adding unique namespaces to isolate dependencies. This behavior should be integrated in Composer IMO.
  • 0
    @SuspiciousBug Nope.

    You should always care about dependencies of dependencies - or as it is called correctly transitive dependencies.

    It's what e.g. NPM does entirely wrong - transitive dependencies require the same care and maintenance as main dependencies.

    A bug / security hole / incompatibility in a transitive dependency can break _all_ it's consumers (main / transitive dependencies)... Which is a serious problem.

    Scoping / linking etc to allow multiple versions makes this serious problem grow exponentially.

    If you want a simple example: OpenSSL.

    It's the transitive dependency for many packages, thus when OpenSSL has critical fixes, you must update all packages dependent on it.

    Which are a lot -.-
  • 0
    PHP has a lot of good parts and ok performance these days, the only real problems is that:
    1. The execution model is not suited for larger backends.
    2. Unicode handling is still even worse than in c++
    3. All the bad parts are still there for less experienced coworkers to fuck up your projects in subtle ways with.
Add Comment