Live data from Hacker News

PHP 8

php.net

161–170 of 273 posts

Re: PHP 8

#161
post #80

Earlier quoted context omitted.

I think you have to do webdev to really enjoy it, I never write PHP unless it's something with laravel.

As usual, it really comes down to personal preference. In the past year, I have managed a few things in Wordpress, wrote my own PHP, Flask and node sites; and after all that I would 100 % choose Flask or node over PHP. Node has the advantage of same language back and front, "asynchronous" execution and having both dynamic typing and static typing with TypeScript. And huge ecosystem obviously helps as well. Python als…

I like flask and express, there are simpler than php franeworks like laravel so I can see why one would prefer using them, but django is weird and I could never get used to it. I always felt like there was too much magic.

Re: PHP 8

#162

Earlier quoted context omitted.

I think I had issues even with mbstring, for some characters like "œ". But maybe I'm wrong.

œ works fine with mb_strlen(). What might have been tripping you up is combining character sequences: https://3v4l.org/DM4pC Handling those "correctly" with a string length function gets complicated in any language, as there isn't a 1-to-1 mapping between Unicode codepoints and visible glyphs.

Yes, I think you nailed what my issue was.

Re: PHP 8

#163

Earlier quoted context omitted.

I'm kind of surprised they'd change a core language semantic, even in a major update... won't this make upgrading to PHP8 for a large codebase hard to do with confidence?

Strict types (scalar type hints for method signatures) have been around since PHP 7, and since then I would say it is recommended to always use === (with type check) over == (no type check) so one would have enough time to upgrade it‘s code. And it also just makes sense from the language design perspective to fix that behaviour. Having a major version coming is a good time to fix such stuff imho.

Strict comparison operators have been considered best practice since well before 7.0

Re: PHP 8

#166

Finally, after all these years, Named Arguments! https://stitcher.io/blog/php-8-named-arguments

Thanks for that! The only error I see in their implementation is that we can't use variables for the name like: $name = 'foo'; myFunction($name: 'bar'); Thankfully, we can still pass an array with the spread operator like: $name = 'foo'; $array = [$name => 'bar']; myFunction(...$array); I wonder if this would work: $name = 'foo'; myFunction(...[$name => 'bar']); Thankfully it's rather unlikely that someone would use…

It works https://3v4l.org/qY3os

Re: PHP 8

#167
post #150
post #86

Earlier quoted context omitted.

I don't understand why pretty much no language does that these days. I think the argument is that your IDE should do this, and it does in some cases, but still...

Python, Kotlin and C# all support named arguments, and they're pretty popular languages. And also... there's Visual Basic.

I guess you can add dart and maybe ruby and elixir if you accept that they treated as a map/keyword list on the receiving end of the function.

Edit: Ruby apparently made them first class citizens back in 2014. Ive been oblivious to this for years... wow.

Re: PHP 8

#168
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's really int + array or string + file_descriptor, things like that

I haven't personally used PHP in years, but was curious about this. Based on some quick/dumb experiments it appears int + array has thrown errors as far back as PHP4:

- http://sandbox.onlinephpfunctions.com/code/0b2f22ea881b36e58...

- http://sandbox.onlinephpfunctions.com/code/0e5fb752fc3ec28e8...

Is the post talking about some other scenario? Maybe the new thing is that it's now specifically a TypeError?

Re: PHP 8

#169
post #157

Earlier quoted context omitted.

technically they'd just crash that one php process, not the whole web server. :) I think the bigger 'why not' is ... 25 years of backwards compatibility.

Oh right ^^ that’s actually one really cool thing about php web apps, no easy denial of service attacks

(again) technically it could trigger a warning (actually, I thought perhaps it did that years ago??)

It's still pretty easy to DOS the server that is passing requests to PHP.

The 'shared nothing' approach has other benefits though - primarily not having to concern yourself with concurrency issues or shared memory resources. You can dive in to deep PHP and do that, but it's not something beginners need to be thinking about.

Re: PHP 8

#170
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-...

Wow, that Wordpress blog is bad. I have seen a lot of projects add support for PHP 8 in recent weeks and they were all kind of easy. Mostly waiting for upstream packages to be ready.

You get nice warnings for years about stuff to fix. If you ignore them because that is easier, there comes a point where it is so bad that you cannot recover.

I know the Wordpress codebase is nasty. But how and when are they going to fix these things? It is going to be so hard.

Post reply on HN