Live data from Hacker News

PHP 8

php.net

131–140 of 273 posts

Re: PHP 8

#131

I haven't touched PHP for a long time now. How is the Unicode support now? I remember having to use some special utilities to handle characters like "œ" properly.

You cannot use the "basic" string manipulation functions (strcmp, strlen, etc.) because these are not unicode-aware.

However, you have the multibyte string functions family that can operate in a wide range of encodings (including UTF-8 which is the default in any sane installation nowadays).

[1] https://www.php.net/manual/en/ref.mbstring.php

Re: PHP 8

#132

How should one start learning with PHP these days? My experience: hacked together a few PHP scripts over the years to notify me of a website change (5 minute cron job). Before that, I was a very good beginner with VB6 back in highschool. There are a couple of ambitious database-driven website projects I would like to create, but I don't know where to start. I like the KISS philosophy, and I think PHP and MySQL would…

Have you considered SQLite? PHP has support for it built-in (php-sqlite3 package in Debian) and you wouldn't have to manage a database server. Concurrent requests should be fine since SQLite does R/W locking and supports transactions.

I can't personally comment on how well it works for websites but I have used PHP+SQLite for local ad-hoc GUI apps and it was a pretty nice experience.

Re: PHP 8

#133

Facebook’s backups were written in PHP. Well, the second version was, anyway. (The first version didn’t work so well.) By backups, I mean the central MySQL databases with profile and post information; not media or messages. The “Crown Jewels,” so to speak. It was written by an engineer in a week or so and then handed off to me. I was a storage guy with some programming chops. Fewer chops than I thought. Multiprocess,…

Why did you switch to Python? Surely it wasn't as perfomant and you already had a working solution.

Mainly to get off HPHP and relieve both that team and ours of the constant coordination and toe-mashing. We thought “modernizing” the code would be a better investment than jerry-rigging the Zend engine back into our infrastructure. I think it was the right call.

Also, with Python we could interact with other services using basic Thrift bindings, and even provide our own endpoints. With PHP, all RPCs and queries were prebuilt into our standard libraries with custom glue code that increasingly made non-Zend assumptions. Again, we could have made it work, but we would be swimming against the current.

All the rest of the database management code ended up being moved to Python, and benefitting greatly, so it eventually worked out.

In summary, organizational concerns.

Re: PHP 8

#134
Where's the best place to suggest a new feature or improvement for PHP?

I've always wanted to see `foreach` get a built-in iterator/counter so you don't have to create and use a counter variable manually.

Current way:

$i=0; foreach ($array as $key => $value) { echo "Loop $i of " . count($array); $i++; }

Possible new way:

foreach ($array as $key => $value, $i) { echo "Loop $i of " . count($array); }

Re: PHP 8

#135

I haven't touched PHP for a long time now. How is the Unicode support now? I remember having to use some special utilities to handle characters like "œ" properly.

You cannot use the "basic" string manipulation functions (strcmp, strlen, etc.) because these are not unicode-aware. However, you have the multibyte string functions family that can operate in a wide range of encodings (including UTF-8 which is the default in any sane installation nowadays). [1] https://www.php.net/manual/en/ref.mbstring.php

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

Re: PHP 8

#136
post #128
post #106

Earlier quoted context omitted.

I worked at WordPress for half a year, and I'm no expert, but the code reviews there were more intense than any I've ever experienced. Every line of code gets reviewed before it gets committed, and if the commit is longer than 20 lines or so, it undergoes an additional scheduled review as well as pre-commit review. They also have pretty good code sniffers that ought to catch errors like OP mentioned. The reason they'…

> WordPress has always been huge on backward compatibility. Yes, and I think that's ultimately the root of its challenges. A fear of breaking things means WP shies away from large-scale changes that would help it become a modern-looking PHP app. I wrote this two years ago, and WordPress's basic architecture hasn't changed since: https://medium.com/@muglug/improving-wordpress-with-static-a...

> A fear of breaking things means WP shies away from large-scale changes that would help it become a modern-looking PHP app.

They are strongly advocating Javascript as the future of WordPress right now, so I'm not sure if they would like it to become a modern looking PHP application.

Re: PHP 8

#137

Where's the best place to suggest a new feature or improvement for PHP? I've always wanted to see `foreach` get a built-in iterator/counter so you don't have to create and use a counter variable manually. Current way: $i=0; foreach ($array as $key => $value) { echo "Loop $i of " . count($array); $i++; } Possible new way: foreach ($array as $key => $value, $i) { echo "Loop $i of " . count($array); }

[deleted]

Re: PHP 8

#138
post #60

Earlier quoted context omitted.

Same as many web languages, PHP's heyday has a reason as many toolkits at that time were far less powerful and complicated for even simple things. Perl+CGI + all the server setup for a simple dynamic page? It's just unimaginable to many today's developer. I started off with PHP3 and have a very great and hated time with it till v5. PHP for sure is difficult to maintain and very painful to debug, but it's not my reaso…

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

Re: PHP 8

#139

Where's the best place to suggest a new feature or improvement for PHP? I've always wanted to see `foreach` get a built-in iterator/counter so you don't have to create and use a counter variable manually. Current way: $i=0; foreach ($array as $key => $value) { echo "Loop $i of " . count($array); $i++; } Possible new way: foreach ($array as $key => $value, $i) { echo "Loop $i of " . count($array); }

https://wiki.php.net/rfc

IMHO that array/map data structure is one of PHP's biggest sin. So many bugs as the result of it and it makes a lot of codebases barely readable.

Re: PHP 8

#140

Facebook’s backups were written in PHP. Well, the second version was, anyway. (The first version didn’t work so well.) By backups, I mean the central MySQL databases with profile and post information; not media or messages. The “Crown Jewels,” so to speak. It was written by an engineer in a week or so and then handed off to me. I was a storage guy with some programming chops. Fewer chops than I thought. Multiprocess,…

PHP is surprisingly good at multiprocess and forking. Though their are plenty of things that can go wrong with using pcntl_fork() in regards to memory/sockets.(Most base PHP classes are not written with explicit multiprocess handling.) I have written a couple different message queue/worker systems in PHP with forking and it always surprised people when they ask what language the system is written in.
Post reply on HN