Top
Best
New

Posted by netol 11 hours ago

What's New in PHP 8.6(www.php.net)
248 points | 120 commentspage 3
shdon 9 hours ago|
I guess the clamp function really is needed, as even in their release notes, they did the clamping using min/max incorrectly.

Their PHP8.5 examples are written as:

  var_dump(max($value, min($lower_bound, $upper_bound)));
but that should be:

  var_dump(max($lower_bound, min($value, $upper_bound)));
/facepalm
Heliodex 54 minutes ago||

    max($value, min($lower_bound, $upper_bound)) when $value < $lower_bound: $lower_bound
    max($value, min($lower_bound, $upper_bound)) when $value > $upper_bound: $value
    max($value, min($lower_bound, $upper_bound)) when $value is between them: $value

    max($lower_bound, min($value, $upper_bound)) when $value < $lower_bound: $lower_bound
    max($lower_bound, min($value, $upper_bound)) when $value > $upper_bound: $upper_bound
    max($lower_bound, min($value, $upper_bound)) when $value is between them: $value
If the former was what's actually written then yeah, it would be incorrect. However, if you swapped arguments 1 and 2 for each clamp() call, they'd give the same result, and for what you say the PHP 8.5 example is written as, there's no call given where $value > $upper_bound.

I don't know if this makes much sense, though that's all the more reason for needing clamp().

TimWolla 8 hours ago|||
> Their PHP8.5 examples are written as:

That is false. The bounds are [0, 100] in both examples and 0 is correctly put as the first parameter to max() in 8.5.

6510 6 hours ago||
I would actually write it like:

    $value = max($value, $lower_bound);
    $value = min($value, $upper_bound);
    var_dump($value);
10 years from now I can thoughtlessly scan over that without having to think what is going on.

This is great:

    clamp($value, $lower_bound, $upper_bound);
It's even more readable.

And since I cant stop typing... (sorry lol)

    $trucks  = trucks($ordernum);
    $boxes   = $boxes_per_truck * $trucks;
    $bananas = $bananas_per_box*$boxes;
    $bananas = max($bananas, $lower_bound);
    $bananas = min($bananas, $upper_bound);
    var_dump($bananas);
In stead of:

    var_dump( max($lower_bound,min($boxes*$bananas_per_box*trucks($ordernum)*$boxes_per_truck,$upper_bound)));
tosti 4 hours ago||
Yes. Write code like how you would do math on paper. Code should be readable without syntax highlighting. Turn it off and it's easy to tell where readability is poor.
origini 10 hours ago||
Ah yes the clamp() function good thats in
AuthorizedCust 7 hours ago||
Why is this language still around?

I get the popularity and installed-base arguments, but I shudder when I see the code.

rarisma 9 hours ago||
Perhaps it will contain something new that will come back to haunt us in six or so months.
HackerThemAll 9 hours ago||
> What's New in PHP 8.6

New CVEs/RCEs? https://www.php.net/archive/2026.php#2026-11-18-1

phplovesong 9 hours ago||
Still no builtin unicode support? What the hell is this? A web language that does not default to unicode, thats pretty weak for a language in 2026
downsplat 7 hours ago||
The php convention is that strings are bytes, but we store utf8 in them. Convert or validate at ingestion, transform using the mb_* family of functions, and be happy.
phplovesong 5 hours ago||
I have heard this exact answer for decades. The mb_slop_uppercase() is not, and should not be acceptable for any modern language.
downsplat 5 hours ago||
It's a big world out there, it's not like you don't have a choice. I quite like the model.

Perl was famous for excellent native unicode support in its native string type, but the result was that you had to keep track of whether your variable was native unicode or octets, and many CPAN modules would try to transparently support both, in buggy ways. A richer system is not always an advantage.

vrubleg 8 hours ago||
The idea of UTF-16 strings in PHP 6 were a mistake. UTF-8 works in PHP just fine. New languages (e.g. Rust, Go, Swift) stick to UTF-8. UTF-16 is legacy that would be nice to get rid of where it's used (Java, C#, JS, WinAPI), but that is impossible because of backwards compatibility.
downsplat 5 hours ago|||
Hindsight is 20/20, it's easy now to say that if Unicode had been utf8 from the start, no 16-bit encoding would have been needed anywhere. But someone had to think of it first, and in the real world, 16-bit came first and became quite entrenched.
phplovesong 5 hours ago|||
PHP6 was such a huge lol overall. The core devs seem so far gone its crazy. I see the odd php apologist every now and then, but luckily PHP use has been on the decline for the last decade and a half.
40four 5 hours ago||
Obviously PHP 6 was a huge “lol”, they abandoned the version number completely. I didn’t start working with PHP until v7 so I missed all of that, but what does any of that have to do with v8.6? Seems like you just want to resurrect ancient buried arguments nobody is worried about anymore.
majestic5762 10 hours ago||
What's New in PHP 8.6?

- no RCE

durmusk 8 hours ago||
Hopefully not another php2shell
skeledrew 11 hours ago||
[flagged]
beberlei 10 hours ago|
You say this and there are nginx, Java and Ruby RCE vulnerabilities in the news this week, so I am unsure you are winning points with the 1990s trope that PHP is more insecure than other projects or languages.
skeledrew 3 hours ago||
Well I'm a Python person, so I'm just watching and laughing at it all. I'll be contrite if/when a big news RCE pops up for it that has people similarly scrambling. But until then... :)
shevy-java 10 hours ago|
[flagged]
beberlei 10 hours ago|
Unsure how that is a useful comment where there is literally an nginx RCE out released yesterday that allows the same thing.
michh 10 hours ago||
And a Ruby RCE today. There’s been plenty of Node and Django security vulnerabilities in the past too. And simply demanding everyone rewrites everything in Rust isn’t reasonable - even in “the agentic era”.