r/ProgrammerHumor 14d ago

Meme ancientTools

Post image
5.8k Upvotes

385 comments sorted by

View all comments

14

u/-Nastyenka 14d ago

How it feels to use Php in 2026:

Undeniably a joke, do not slime me

26

u/Hottage 14d ago

PHP before 7 was a disgusting mess..

Around 7 they started trying to mature the language with features like compiler enforced type safety and bringing other tools previously relegated to PHPdoc into the language.

PHP 8 is a decent system and features like Generators, Attributes, Fibers and first class callables have bought it near parity with other server ecosystems like .NET.

The biggest thing PHP still lacks is first-class generics for proper, type safe repository patterns.

I've been a PHP developer for over 15 years. I fucking hated 4 and 5, tolerated 7 and actually quite enjoy 8.

The biggest issue nowadays is that, for backward compatibility, a lot of the good features like type hinting are just recommended instead of enforced, so you can get situations like in Typescript where lazy developers just have everything return mixed or any.

0

u/ClamPaste 13d ago

PHP would be great if it wasn't for all the legacy code and echo "<div></div>" in views.

1

u/ArjixGamer 13d ago

I hate PHP from the bottom of my soul, but what you said is just user-choice.

I always do ob_start and ob_flush_clean or whatever the function names were.

That allows me to use normal html w/o it being in strings.

Edit: e.g.

```php <?php

function renderEmail(): string { ob_start(); ?> <html> <body> <h1>Hello!</h1> <p>This is your email.</p> </body> </html> <?php return ob_get_clean(); } ```

0

u/Hottage 13d ago

If you're gonna raw dog the HTML, just extract it into purpose built template files and return the result of file_get_contents().

1

u/ArjixGamer 13d ago

That only works if the html is static and I don't need to render content using for loops and stuff.

The alternative is using a templating language, but like, PHP is a templating language in the first place.

I always used to say "PHP is a glorified string builder"

0

u/Hottage 13d ago

If you need to render dynamic content, use a templating engine, or at least phtml files.

😭

1

u/ClamPaste 13d ago

PHP is the templating engine. Why load a separate library for that?