Live data from Hacker News

PHP 8.5

stitcher.io

101–110 of 197 posts

Re: PHP 8.5

#101

Is PHP still unhelpful when it comes to writing secure code? I remember when escaping SQL input data was "the correct way" to use your mysql database. Parametrization? Nah, just use mysql_escape_string or whatever it was called.

SQL named parameters was a feature introduced into PHP on 24th Nov 2005, with the release of PHP 5.1.0.

Re: PHP 8.5

#102

Is PHP still unhelpful when it comes to writing secure code? I remember when escaping SQL input data was "the correct way" to use your mysql database. Parametrization? Nah, just use mysql_escape_string or whatever it was called.

Prepared statements have been available in PHP for over 20 years, when it deprecated the old mysql libraries. They were removed entirely in PHP 7.

And let's be real - most handwritten SQL code in existence in most languages just builds queries from concatenated strings, even when more secure options exist. A lot of code doesn't even bother to escape anything. That's not a language problem so much as a developer laziness and assumption that "simplicity always equals correctness and frameworks are always wrong" problem.

Re: PHP 8.5

#103

Is PHP still unhelpful when it comes to writing secure code? I remember when escaping SQL input data was "the correct way" to use your mysql database. Parametrization? Nah, just use mysql_escape_string or whatever it was called.

You use PDO and prepared statements. Although realistically, you are going to be using a framework and some kind of Active Record pattern.

Re: PHP 8.5

#104
Do people have any recommendations for modern PHP tutorials and learning sources?

Re: PHP 8.5

#105
post #85

The pipe operator example omits the typical way you would write this code in any language: simply by introducing temporary variables or by shadowing. The url parse example is not being compared to the builtin parse_url function that is just as easy to use.

Parse_url isn't standards compliant, often fails with relative url's and most importantly only parses urls, not uris (with the exception of file://). I also find it's syntax clunkier than the new uri(), but that's just personal preference.

The pipe operator is indeed just syntactical sugar (and the article links to another article specifically about it which does cover the case of temporary variables), but with the coming partial function application feature it (in my opinion) will make easier to read/reason chains of code than temporary variables or nested function calls.

Re: PHP 8.5

#106

PHP's evolution since PHP 5 has been substantial, and I think this is a real problem. As someone who learned the language years ago, the pace of change (generics, attributes, match expressions, typed properties) makes modern codebases genuinely difficult to follow. I suspect this affects many developers who cut their teeth on PHP but haven't kept up. The language has become a different beast, which is a strength for…

To be fair, that’s true of many languages and programming domains. The web, in particular, is one where you have to keep pace or end up out of the field.

Java and C# are a couple other popular languages where the same is also true.

Re: PHP 8.5

#107
post #104

Do people have any recommendations for modern PHP tutorials and learning sources?

Yes, see: https://news.ycombinator.com/item?id=39989663

---

Books:

* PHP & MySQL: Novice to Ninja by Tom Butler

* PHP 8 - Quick Scripting Reference by Mikael Olsson

* PHP 8 Objects, Patterns, and Practice by Matt Zandstra

* Programming PHP (2020) by Kevin Tatroe and Peter MacIntyre

I personally found them to be really good. I learned a lot from the first book especially.

You can find the code from the first book here: https://github.com/spbooks/phpmysql7

I hope this helps.

Re: PHP 8.5

#108

PHP's evolution since PHP 5 has been substantial, and I think this is a real problem. As someone who learned the language years ago, the pace of change (generics, attributes, match expressions, typed properties) makes modern codebases genuinely difficult to follow. I suspect this affects many developers who cut their teeth on PHP but haven't kept up. The language has become a different beast, which is a strength for…

PHP has no generics? I read somewhere that is was "too hard" to get right in PHP land, mostly because of how primitive the typesystem is.

You are probably talking about this: https://stitcher.io/blog/generics-in-php-3 . If I remember correctly, the author claims it will either cause runtime overhead or extreme memory overhead. The best solution is to introduce a typed superset of PHP like TypeScript was done for JavaScript.

Re: PHP 8.5

#109
post #28

I still love PHP. 23 years ago we created some encryption software for it and it is still going. I also run a PHP newsletter. There's still a strong community of people and whilst there are other languages which I also use (Python, Node.js) I still find myself gravitating towards PHP for fast and simple work The only issues I have. is that this is a 'double edged sword' in that PHP has become far more complex since t…

I think PHP 8 is easy to understand if you write it from scratch, you just have to learn doing things the right way, read up on PSRs and so on. It is a bit more complex but much more secure and supports quite a lot of things now that are definitely helpful to have.

Re: PHP 8.5

#110
post #71

Earlier quoted context omitted.

I am quite sure many people would fail Pub Quizzes related to C, when taking into account the whole language alongside compiler extensions, regardless of the compiler.

To learn all of the common GCC and MSVC extensions would make up a fraction of the language features of C# or Java. You’re really overstating the complexity to make some invalid point. “Actually, one of the most notoriously conservative and simple (in feature set) languages is really super complex and has evolved a ton because it has _Generic and varargs now, and __packed__ exists as a compiler feature.” And to furth…

Yeah, it does not take a long time to learn GCC / Clang extensions, IMO. Have an LLM give you a list of these with examples, really. :P
Post reply on HN