Live data from Hacker News

PHP 8

php.net

181–190 of 273 posts

Re: PHP 8

#181
post #19
post #4

Apparently some of the deprecations will make this the most backward compatibility breaking version jump of PHP since V4 to V5. (Read a german interview here: https://www.heise.de/news/PHP-8-im-Experten-Check-Der-erwart... ) There's a long report on Wordpress and PHP 8 and it's not pretty: https://developer.yoast.com/blog/the-2020-wordpress-and-php-...

Reading the list of things that worry them makes it clear that it's not so much php is breaking bc than it is wordpress lack of cleaning and linting for so long catching up to them. I mean seriously the first thing they list as a worry is that arithmetic operators will now throw an error when one (and only one) of their operand is an array or resource (eg array + array support remains, it's really int + array or stri…

It also sounds as though the internal type checking is going to be a large developer load as well. In PHP7, internal functions return null for type mismatches, and in PHP8, they raise a TypeError. This means going back through every case where they call an internal function and wrapping it with a try/catch for TypeError, in addition to checking for null. That sounds like a pretty significant workload change.

Re: PHP 8

#182
post #138

Earlier quoted context omitted.

> Perl+CGI + all the server setup for a simple dynamic page? It's just unimaginable to many today's developer. TBH, I'm still not aware of any truly simple/easy way to get a dynamic HTML page. Recently, I had to make a dumb utility app to render some dynamic data, and I wound up writing a Golang server with the HTML specified as a Go Template. But making it accessible on the publc internet still required spinning up…

Have you tried Caddy as your reverse proxy? It's much simpler compared to nginx and it has very robust, integrated LE support. It's also packaged for Debian and CentOS now. Write a systemd unit file for your golang service, put Caddy in front of it and you are good to go. It's not a PaaS, but it's simple and shouldn't be too difficult to maintain.

> Write a systemd unit file for your golang service

Oh yeah, I forgot I had to do that, too! Another step.

I'll take a look at Caddy!

Re: PHP 8

#183

I got spoiled by PHP as my first language. It was so easy to get going. I was surprised to learn that other languages didn't work the same way, when integrating into a web server. Also it has always been rock solid. A bug in my code brought down only that request for that user, totally did not affect or even slow down responses to other users. People have attacked its syntax forever. I avoided the worst of it by lear…

you are doing it right. if you want to use fancy jargon for what you're doing say "I use apache as the controller, the database as the model and php for the view". that's how it's supposed to work since the first version of php/fi. php is primarily a templating engine.

but I disagree concerning register globals. I think it was the single thing that made php the most accessible language. we should bring them back but as a special variable with it's own prefix instead of $

Re: PHP 8

#184

Earlier quoted context omitted.

'foobar' is coerced into a number, which fails for the obvious reason. So it becomes 0, which means the expression is "0 == 0". Terrible, terrible, behaviour but there are lots of similar examples in PHP because it evolved over time rather than being designed as-is. Some of these things are being fixed over time, like this very example, others can't/won't be.

And people say C++ is a complicated language.

Yes because ('0' == 32) returning true makes more intuitive sense. There are languages without type coercion for comparisons (e.g. OCaml), but C++ isn't one of them.

Re: PHP 8

#185

Earlier quoted context omitted.

WordPress core team members and users are welcome to get involved in PHP development and providing feedback on proposals. They are notably absent, and so people who write modern PHP - or wish PHP was a different language - are the ones influencing language development.

> And so people who ... wish PHP was a different language are the ones influencing language development. That's definitely been my impression. I used to be a professional PHP developer, still use it occasionally for personal projects, and appreciate the language, warts and all, even if I can't truly say I love* it -- but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of P…

> - but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of Perl into a cargo cult version of Java.

It's a joke in so far as it is funny - but it's absolutely correct. When you only look at the language... When looking at the VM, Java has an absolutely world class VM, with great engineering and decades worth of research poured into it.

PHP has... no such thing.

Re: PHP 8

#186
post #39

Does PHP still has that weird flow where each request is its own process? afair PHP never had an http server baked in, I remember nginx with php etc ...

Surprisingly php these days is actually pretty fast even on forking webserver such as apache. This annoy me to no end because I prefer to use python and django and it can't match php performance on apache even though it handles http requests directly.

Are you using mod_python with Apache? If so, mod_wsgi is what you should be using for Apache + Django applications. mod_wsgi is fantastic and I see no issues with performance matching similar PHP setups via PHP-FPM.

Re: PHP 8

#187
post #180
post #62

Earlier quoted context omitted.

Modern PHPs shining light is the Laravel framework and the ecosystem built up around it. If you're going to start a database-driven website projects in PHP there really isn't a good reason to not use and learn Laravel (or Lumen if you want something more lightweight). That being said if you're not tied to PHP I'm not sure I'd necessarily recommend it. The obvious alternatives worth looking into are Ruby on Rails or P…

Is Laravel better than Symfony? When I used PHP, the Symfony components were the best in the ecosystem.

"Better" is relative. Laravel is built on top of Symfony components FWIW.

Re: PHP 8

#188
It's nice to see the language being cleaned up a bit.

PHP was the first language I learned, but the more I used and read code written in other language, the more PHP seemed like a mess, and it got worse the more features are being bolted on.

Re: PHP 8

#189

Earlier quoted context omitted.

'foobar' is coerced into a number, which fails for the obvious reason. So it becomes 0, which means the expression is "0 == 0". Terrible, terrible, behaviour but there are lots of similar examples in PHP because it evolved over time rather than being designed as-is. Some of these things are being fixed over time, like this very example, others can't/won't be.

> Terrible, terrible, behaviour but there are lots of similar examples in PHP So true. One I ran into recently was comparing hashes that start with '0e' and contain only a numeric component after that prefix. Failure to use the identity operator means that you can have two different hashes returning... equality. PHP apparently thought it a good idea to coerce that into 0 raised to an exponent, which of course always…

Is this fixed in php 8? I did not think this was possible as there is no type coercion and not well documented. [1][2]

Noticed "0.2" == "0.20" as another example

[1] https://www.php.net/manual/en/language.operators.comparison.... [2] https://www.php.net/manual/en/language.types.type-juggling.p...

Post reply on HN