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…
PHP 8
161–170 of 273 posts
Re: PHP 8
#162Earlier 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.
Re: PHP 8
#163Earlier 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.
Re: PHP 8
#164Re: PHP 8
#165Re: PHP 8
#166Finally, 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…
Re: PHP 8
#167Earlier 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.
Edit: Ruby apparently made them first class citizens back in 2014. Ive been oblivious to this for years... wow.
Re: PHP 8
#168Apparently 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…
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
#169Earlier 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
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
#170Apparently 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-...
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.