Live data from Hacker News

PHP 8

php.net

151–160 of 273 posts

Re: PHP 8

#151

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…

> How should one start learning with PHP these days?

there is learning PHP and its standard lib, learning how to avoid all the PHP pitfalls (because there are a lot of them when it comes to webdevelopment) then learning some mandatory framework because that's how you get an actual PHP job. These 3 things are separate tasks.

For the first frankly it's the documentation + stackoverflow, the second is https://phptherightway.com/ , the third is the documentation of whatever framework you are using. Final step is to learn how to use whatever server that will front your PHP app, Apache or Nginx.

Re: PHP 8

#152
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…

Laravel is good and bad for the ecosystem at the same time. I've interviewed a lot of people lately who know laravel but not php. Similarly to people who claim they know react but fail in the most basic js questions.

Additionally Laravel abuses patterns like singletons and in general static methods. This is really a no-no for modern PHP, in my opinion. I think Symfony had a way better impact on the ecosystem.

Re: PHP 8

#153

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,…

Did you use those backups often?

Re: PHP 8

#154
post #145

I can't believe nobody has pointed out (yet) that PHP is the quintessential lambda :) That said, it's been many (many, many!) years since I moved away from it, but I'm intrigued by the state of the JIT and the current coding style (last time I checked, around 6.x, it was growing to be verbose and full of backslash-adorned-namespacing).

"PHP was serverless before there was serverless"

However there is a difference: PHP has no deployment system included. But if you build that (not too hard) the difference isn't big ... (But with Lambda&others you outsource the management)

Re: PHP 8

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

Re: PHP 8

#156

Earlier quoted context omitted.

> This is literally a case that makes no sense in the code ever, Speaking as someone that hates PHP but still appreciates that it has its uses: You’re speaking from one perspective. There are others. That operation is perfectly valid and well-defined in Matlab where it increments all members of the matrix/vector by the scalar.

Did it php use to do that? Otherwise your point is invalid.

[deleted]

Re: PHP 8

#157
post #91

Earlier quoted context omitted.

> Why couldn't this just be an error? you mean crash your program? So your user finds a way to send you an int instead of a string, or vice versa, and now they can crash your webserver.

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

Re: PHP 8

#158

Earlier quoted context omitted.

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.

œ 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

#159

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); }

For that code snippet specifically, you're actually better off pre-declaring the vars since the loop repeatedly calls `count($array)` but hopefully(!) its size doesn't change over time. Is there such a function in php like "enumerate" in python, that yields a tuple of (counter, item) for each item in the first argument to enumerate? That is to say: is it possible to do what you're asking with composition rather than…

Since count is it's own opcodes in the VM and php hashtables keep the number of elements around and don't have to be counted there shouldn't be much difference between reading a variable and calling count.

(Since some time in PHP 7, before that count() went via function call overhead)

Re: PHP 8

#160
post #66

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…

Every language I think about is better than PHP (Javascript, Python, Ruby). Personally I will choose Javascript / Node JS platform to start with.

why? Those three come with the same amount of quirkiness and issues. There is a reason why you have Typescript or golang, for example.
Post reply on HN