Settings

Theme

PHP 7.3.0 alpha 1 Released

php.net

62 points by flavius37 8 years ago · 48 comments

Reader

dlbucci 8 years ago

I recently revisited some of the earliest web code I ever wrote, which was in PHP 5.5 (about 7 years old, I think). I wasn't surprised by all the mistakes I made, both from being a newbie programmer and from making what I think were fairly easy-to-make PHP mistakes. After all, every tutorial I could find back then used mysql, didn't used real_escape_string, etc.

What was surprising was how hard I had to dig now, 7 years later to find out how to do things correctly in PHP 7. Searching for what I thought should be fairly common things to do seemed to bring up all of the old articles that I first mislearned from, and it was really hard to find things like what the best way to iterate over a mysql result set was.

Honestly, after putting my 7 years of experience to practice, the final code didn't look half bad, but I don't think I'll ever end up using PHP since it still appears to be very easy to write bad code. Maybe if a definitive guide for how to write good PHP shows up, I'll give it a shot (or maybe I'll just try Hack).

  • prplhaz4 8 years ago

    http://www.phptherightway.com/ attempts to do just that - can't vouch for its effectiveness, but is a resource that was at least updated for PHP 7...

    https://github.com/codeguy/php-the-right-way

    • TooBrokeToBeg 8 years ago

      I always hated the DI fervor in PHP, like it solves all problems. You get such gems from phptherightway as

      > We can demonstrate the concept with a simple, yet naive example.

      > Here we have a Database class that requires an adapter to speak to the database.

      It tries so hard to be java, which seems backward.

      • RossM 8 years ago

        If you remember that so, so much old PHP was reliant on global scope included from other files, it explains a lot of the DI obsession. If you were lucky, it was just a single bootstrap.php, but often not.

      • pan69 8 years ago

        Just like when demonstrating object oriented programming with trivial examples, DI suffers the same problem. DI, or Inversion of Control (the thing you want to achieve "through" DI), works best at scale, not with Hello World examples. When you work on a large code base with a large team you need some philosophy and principles to guide you. Decoupling is one of those things. Since Java is often used to build large software projects you will see these techniques being used and we therefore associate these things with Java (i.e. the Java bloat). Over the past few years it seems that PHP has become an "easier" Java and it's therefore only natural that these techniques and approaches are then also applied.

      • __aeneas 8 years ago

        I can only agree. I wrote a CMS with Zend Framework 2 which is heavy on DI and tries to be like Spring + Hibernate (Doctrine). Apart from being very hard to understand for new devs in the project, it's also very, very slow.

        The way PHP is evolving is definitely towards the Java world and I think it's the worst decision they could make.

        Moved to Go 5 years ago, never looking back.

        • trm42 8 years ago

          Haven't had to use Zend but at least Symfony DI is really heavy to use with all the services.yamls and the javaisms it introduces.

          DI can be heavy or it can be something mostly automagical like in Laravel. That's something I've enjoyed quite a bit. Basically it doesn't that much exist until you start needing special cases.

          Quite a big part of the PHP community is gravitating towards Laravel and the new steam it introduced with OOB best practices and "let's try hard to avoid the Java-heaviness". Laravel seems to have quite nice balance between easy for new devs and bunch of powerful concepts when needed. Lots of basic problems solved OOB as well.

      • edgarvaldes 8 years ago

        What is DI?

  • closeneough 8 years ago

    This is also a initiative to improve this situation:

    https://paragonie.com/blog/2018/01/our-ambitious-plan-make-i...

  • cujo 8 years ago

    There are resources for that...

    http://www.phptherightway.com is often recommended in my circles.

  • mgkimsal 8 years ago

    > but I don't think I'll ever end up using PHP since it still appears to be very easy to write bad code

    I was in the Java world for many years, and found it to be incredibly easy to write 'bad' code. Sure it looked OK, but whenever there was a problem... i would just have people telling me it was 'wrong' and 'bad', but rarely ever any 'good' way to do something, short of entirely rebuilding in someone else's preferred library/framework/stack.

    Loads of "well, that never happens to me", "works fine", etc. Was it tomcat? which version? was it one of the 95 dependencies interacting with tomcat in a way no one had ever hit? Oh shit - you're using tomcat? WTF? Glassfish/jetty/jboss are the only 'real' tools to use... etc.

  • deathtrader666 8 years ago

    Why not fall back on a microframework like Slim, or something that has best practices built-in like Laravel or Symfony.

    7 years ago we had Codeigniter, which was also quite good.

  • NVRM 8 years ago

    That's right, google search in past year only, btu focus on the php.net docs.

  • scns 8 years ago

    phpdelusions.net

    • scns 8 years ago

      should have written more, was in a hurry. Even though the url sounds inflammatory, it is actually a really helpful resource on how to do dbaccess correctly.

mmosta 8 years ago

  - JSON:
  . Added JSON_THROW_ON_ERROR flag. (Andrea)
A blessed day, prior to this, json_decode would simply return null on error.
  • LeonM 8 years ago

    Absolutely, before you had to do some check like:

    if(null === $data = json_decode($json)) throw new Exception();

    • rollcat 8 years ago

      Wrong! "null" is a valid JSON-serialized value! You MUST call json_last_error.

      Better yet - don't use PHP.

tylerjwilk00 8 years ago

Notable New Stuff in Core

- list() Reference Assignment

  https://wiki.php.net/rfc/list_reference_assignment
this allows using list() function for reference assignment instead of just assigning to new variables

- Flexible Heredoc and Nowdoc Syntaxes

  https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes
This makes using HEREDOC blocks much more friendly looking for spaces/tab usages in code

Other stuff

Just a lot of updates and bugfixes to many extensions

pasta 8 years ago

Removed support for BeOS

It's amazing a lot of software still support some very old stuff :)

bovermyer 8 years ago

Maybe I should take this as an opportunity to write a new app in PHP. I've been too deep into Go for awhile to have any sense for where PHP's at these days.

  • mmaunder 8 years ago

    If you want to be cool, write Go. If you want to make money, write PHP.

    • mtberatwork 8 years ago

      > If you want to make money, write PHP.

      Eh, if we're strictly speaking about making money, then Java is the way to go. It'll open up your career opportunities much farther than PHP.

    • ergo14 8 years ago

      Are you implying PHP devs are earning more than Go devs?

      • bovermyer 8 years ago

        That's an interesting question.

        My impression (based on nothing more than anecdotal industry experience) is that there are far more jobs for PHP globally, and that the average starting salary for a new PHP dev is going to be considerably lower than the average starting salary for a new Go dev.

        However, the number of stable senior PHP dev jobs with high salaries is also likely far higher than for Go.

        I imagine it's easier to earn more as a new Go developer if you can get a job doing it, but it's easier to steadily get raises as a PHP developer.

      • jdpedrie 8 years ago

        I don't speak for the parent (and I don't think the assertion is correct), but I will say that PHP jobs outside the valley are plentiful. A large percentage of those are legacy maintenance or development on unpleasant platforms such as WordPress or Magento, but there is still a lot of challenging and enjoyable work being done using PHP, and the improvements to the language over the last few years have made many of the old arguments against the language obsolete.

        • ergo14 8 years ago

          I'm asking about salary ranges specifically.

          • cleong 8 years ago

            That might not be a good measure, take a language related to PHP like Hack. The min salary for this language will be six figures because the only company that uses it is Facebook. PHP is a widely used language that your not going to have problem finding a job with.

          • jdpedrie 8 years ago

            StackOverflow's developer survey[0] would suggest that the original comment was incorrect. But I think it's an incomplete story for the reasons I and other respondents mentioned. The large supply at the lower end of the market depresses salary, but as one rises, salaries are in my experience comparable to any other widely-used language.

            [0] https://insights.stackoverflow.com/survey/2018/#work-salary-...

          • waibelp 8 years ago

            I know some php devs from munich in germany which started at 64k per year. Others earn 70k+ per year. In agencies (wordpress i.e.) jobs start at 48k.

            • foepys 8 years ago

              Tbf, 70k€ in Munich is like 50k€ nearly anywhere else in Germany.

      • TooBrokeToBeg 8 years ago

        Individually no. In aggregate salaries, yes.

creeble 8 years ago

what does it break from 7.2?

I love how every php upgrades requires me to find mysqli-type crap that breaks all my customers' code.

  • wolfgang42 8 years ago

    Seems to be mostly fixes and incremental improvements. Here's the only breaking changes I see in NEWS:

    . Removed support for BeOS. (Kalle)

    . Removed support for ODBCRouter. (Kalle)

    . Removed support for Birdstep. (Kalle)

    So, if your customers are still using BeBoxes, you might have a problem.

olskool 8 years ago

Did PHP ever change the misfeature that there is no warning when you reference an uninitialized variable?

  • JeanMarcS 8 years ago

    If my memory is correct (might not be) you get a Notice since PHP5. So around 13 years ago.

emodendroket 8 years ago

What's new in this release? I couldn't figure it out by looking at the page.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection