BackBack
Technical Blogs - 02/06/2023

PHP - Is it still useful?

Truong Nguyen

Truong Nguyen

Software Engineer, Back-End
Sao chép link

For those who do not know, PHP is a programming language often used to create websites. As of September 2021, nearly 80% of websites in the world use PHP, considered the most popular language for developing websites worldwide.

 

 

Why did I write "PHP - Is it still useful?"

 

I know how professional friends have compared the programming languages. They are talking about not learning PHP. The other programming language is better, PHP is not high efficiency, PHP is the dead language, etc.


In terms of personal opinion, each person will have their ideas. We do not say that their views are wrong and our beliefs are correct; writing this article is to stand out and protect the PHP language. The language that I use every day and even do for a living.


The most common in PHP world is WordPress. It is a free, open-source CMS that can help users deploy a website or blog without knowing the code. According to unknown statistics, 40% of websites are built with WordPress.

 

 

My memorable experience with PHP

 

PHP is known for its ambiguous data types, which can be confusing for those new to the programming language. When I was applying for a programming job at my previous company, Divine Corp, I struggled with this issue multiple times due to its virtual nature. To illustrate, here's an example:

 

 

What do you think the above example will return?

 

Looking at the above code, we see that they are comparing $a and $b variables. More specifically, they compare “1” and “1 iPhone”. Logically speaking, the number “1” cannot equal “1 iPhone,” but the result above is the same when you run it with PHP 7.4 or below.

 

 

Why is that?

 

Because we are comparing an integer with a string, PHP will automatically convert the data type of the string to an integer. When converting to an integer, $b will have the value 1. So when comparing with two equal signs (==), it will not reach the data type but will convert and compare itself. So the return result is still valid. The lesson learned here is that absolute comparisons === (3 equals signs) should be used in most cases and that you should actively convert data types (if necessary) before comparing them.

 

 

I'm different now!

 

 

When writing this article, PHP has already reached version 8.2. Much faster and more robust than its predecessors. For those who program PHP object-oriented (OOP), it is advisable to declare clear data types for properties, parameters, and methods to avoid virtual situations like the above example I mentioned.


Currently, when programming with PHP to simplify installation and avoid problems such as common security errors and having available or used features, people often use Frameworks such as Laravel, Symfony, CodeIgniter, Slim, Zend Framework...

 

 

My advice for those of you who have been, are and will pursue PHP

 

Before you can learn the more complex aspects of PHP, it's a good idea to have a basic understanding of the programming language. Start with the basics, like variables, functions, arrays, loops, conditions, constants, classes, and objects. You are followed by learning and learning popular frameworks like Laravel, Symfony, CodeIgniter, Yii, CakePHP, and Zend. These frameworks provide helpful features and libraries that help you develop PHP applications more quickly and efficiently. You can also read the source code of these frameworks to learn how they write and implement the code.

 

Learn software development tools like Git, Composer, PHPUnit, Xdebug, Docker, and popular IDEs like VS Code, PHPStorm, NetBeans, Eclipse, and Sublime Text. Understanding web-related concepts such as HTTP, RESTful API, JSON, AJAX, HTML, CSS, and JavaScript is essential for PHP web application development. However, it is related to Front End. Learn about databases like MySQL, PostgreSQL, MongoDB, etc. Learn how to use SQL to query databases and learn concepts like transactions, indexing, normalization, etc.

 

 

Practice is the best way to consolidate knowledge and develop skills. Join open-source projects, or create real projects to apply your knowledge. With the continuous development of technology, keep your knowledge up to date by reading books and blogs, taking courses, and discussing with the PHP developer community. Knowledge can never be known. I hope that you and I continue to study, learn, and study forever so that today's me will be different from yesterday's me. To be more knowledgeable and better on your career path.

 

***

A brief description of myself

 

A little introduction, I am currently a Software Engineer, PHP at Cốc Cốc. Let me tell you a secret: in Cốc Cốc, dozens, even hundreds of services are running in PHP to serve millions of users daily. Therefore, it cannot be said that PHP is disabled. If your system is slow or does not run well, it is because of the way you code and implement the system not well.

 

For the Vietnamese version of my sharing, you can visit this Link.

Loading...