Fahad Al Amoudi

Full Stack Web Developer

Software Engineer

Entrepreneur

Freelancer

0

No products in the cart.

Fahad Al Amoudi

Full Stack Web Developer

Software Engineer

Entrepreneur

Freelancer

Blog Post

Is PHP Still Relevant in 2021?

February 7, 2021 Design, PHP, Technology
Is PHP Still Relevant in 2021?

The conversation has shifted away from PHP to JavaScript and Python. Does PHP still matter?

Burak Karakan
Jan 4 · 7 min read

Two elephants

Photo by Mylon Ollila on Unsplash.

A Brief History of PHP

What Is Wrong With PHP?

Weak typing

echo "1" + 3;
echo 1 + "3";
echo "1" + "3";

Lack of namespaces

Inconsistent standard library functions

Superglobals

What Is Good About PHP?

Type hints

function isValueSomething($value) {}
function isValueSomething(string $value): bool {}

Syntax improvements

Constructor promotion

Instead of having this unnecessarily verbose code, PHP 8 supports writing the following code:
It is neat, isn’t it?

Nullsafe operator

This was how the logic would be written with the older PHP versions with respect to null-checks. The new nullsafe operator allows you to convert this to simply:

Union types

function doSomething(int|string $value): bool|array {}

Performance

Results of benchmark tests

Benchmark results

Conclusion

Taggs:
Write a comment
Back
Whatsapp
Viber
Messenger
Instagram