Let’s cut to the chase. ** PHP is a weird language. It is neither fast nor grammatically beautiful. Good software development practices have not been followed. ** But I still use it to develop a lot of software. So the obvious question is why are we still using PHP today?
There are many reasons beyond a preference for personal idealism. That’s what we’re talking about. Why did I choose PHP as my Web development language?
What is PHP?
“What does PHP stand for?” Or ask, “What is PHP?” PHP is a language for writing Web pages. The bottom layer is implemented in C language, and the code is wrapped by THE tag syntax of HTML. PHP usually runs on the server side and works with a Web server to process the HTML back to the visitor.
PHP originally stood for “Personal Home Page”. Because this completely limits the sense and desirability of using the language for general use, the language now stands for “PHP: Hypertext Preprocessor.” This writing is called a recursive abbreviation (an abbreviation that refers to itself in a full name). It’s a name that geeks like to use.
What can PHP do?
What can YOU do with PHP? In general PHP can do anything you want on a Web server. Like starting a blog. Implementing a SAAS application is also a no-brainer. Writing a script to temporarily process data is also handy. Or write a complex script that one day suddenly becomes a successful software business? It used to happen a lot.
If you don’t believe me, take a look at the PHP website for a list of usage scenarios:
- Server script
- Command line script
- Writing desktop applications
I don’t encourage that last one, but it works. But the first two are really great reasons.
This leads to an important and inescapable fact…
PHP is everywhere
There are many reasons to know and love PHP, and perhaps the most powerful and effective reason is that it can be used and run anywhere on the web. If you look carefully, you can buy a hosting account for as little as $3 a month that can run Python or Ruby Web applications. But it can certainly run PHP. This means you can always rely on PHP.
Because PHP can run anywhere and is easy to use, a lot of very popular software is written in PHP. WordPress is my most influential and familiar example, along with tools like Joomla, Drupal, Magento, ExpressionEngine, vBulletin (yes, it still exists), MediaWiki, They all run PHP on the server.
There are many PHP application frameworks, such as Symfony, Zend, Laravel, Aura, CakePHP, Yii and even the ancient CodeIgnitor framework. Of course you can make a list of Web frameworks of comparable length for any other language. For common Web languages like Python, Ruby, or Node/JavaScript, you can even accumulate a list of numerical contests to compare with PHP. But the number of websites running PHP is unfathomable.
WordPress boasts 30 percent of all users on the Internet. You don’t even have to believe this statement to realize that many Internet applications must use PHP even if it’s conceivable that the statement is true.
The advantages of PHP
Dynamic characteristics
PHP and HTML work very well together. Change file.html to file.php. PHP and? Write PHP code in the > tag, and most Web servers are configured to run PHP scripts by default. Because the barrier to entry is so low, novice programmers who don’t need much programming knowledge can get started, resulting in a lot of low-quality code.
Because of its ease of learning, the influx of novice programmers has exposed another problem PHP has been criticized for: PHP doesn’t have a clear vision of itself as the best Web server-side language, and it certainly hasn’t been well designed to do so. The result was a loose collaboration from around the world, a hodgepodge of contributing code and ideas, and inevitably, some bad ideas seeping in.
Having strong object-oriented package management is now a standard in PHP
Composer is a plus for PHP.
In PHP development, strange things are often published. Most notably, THE GOto declaration was introduced in PHP 5.3 (widely regarded as the first modern version of PHP).
Similar problems arose when PHP was growing up: object orientation was initially implemented as a flawed and limited concept, the standard library was full of inconsistent names and parameter sorting, and (to cite a recent notable example) in PHP 5.3: T_PAAMAYIM_NEKUDOTAYIM syntax error T_PAAMAYIM_NEKUDOTAYIM syntax error T_PAAMAYIM_NEKUDOTAYIM syntax error T_PAAMAYIM_NEKUDOTAYIM
But now PHP has full support for OOP. Few languages have java-like OOP implementations like PHP. Also, unlike Java, PHP has a separate and widely supported package manager called Composer. It is very easy to use, and not to be overlooked is that it can easily reference good and well-maintained libraries, with high ease of use.
The rapid development of PHP
Through these findings, PHP is evolving in interesting ways. It is becoming as full-featured an object-oriented language as Java (better or worse) and is providing simple abstractions for functional programming, which is arguably the hot topic right now. Also, a great set of tools are being developed, and PHP loves Composer, and for good reason – it has made a commendable effort to work together on some large open source projects.
Of course, we shouldn’t forget what’s trending today: the speed with which PHP has developed in the PHP7 series. This was widely thought to have been caused by the advent of HHVM in Facbook, and for a short time there was a risk that HHVM would grow at a rate that would destroy the PHP community, but that wasn’t the case, instead PHP grew so fast that people almost forgot HHVM existed.
PHP has a huge community; It’s friendly to beginners.
If you decide what cool new technology to use, I think what often gets less attention is the way to make agreements with the language. What was it like learning PHP? PHP tutorials are easy to find and usually of good quality.
One downside to the popularity of PHP is that you’ll find some not-so-good teaching from people who don’t know enough about the tool. Or “best practices” learned from someone that are 10 years old. But overall, it’s rare, and I don’t think it should discourage you. Or suddenly discovering that the best practice you’ve been using for months isn’t the best is rare and not a big deal.
PHP compared to other languages
Next, we’ll compare PHP with other languages that meet the following requirements:
-
Open source: means you can use or view the underlying language or program freely and for free;
-
Application in the field of Web development: not necessarily focus on Web development, but there is a relatively large application in Web development;
-
High-level dynamic languages: Have the characteristics of dynamic languages, and most Web-oriented languages have the same characteristics.
-
Large enough community: There are many languages that meet the above criteria, but are only used in small areas, and we use this last criterion to filter them out.
Why PHP? Instead of JavaScript?
Perhaps the most important language to compare PHP to is JavaScript. Modern development requires every project to have at least some JavaScript for client-side development and interaction. With Node, this makes it relatively easy to use JS on the server. Having the same language “isomorphic” on the server and the client is very attractive.
Like PHP, JavaScript is an inclusive but sometimes ugly language with lots of flaws and “traps”, but JavaScript has changed so fast in the past decade that its case is true. Why PHP and not JavaScript? You already have expertise or use libraries in PHP. Otherwise, I think JavaScript might be a better choice.
PHP Compares dynamic Server pages (.NET Core)
The dynamic server language originated as a Microsoft language for user programming. It is very similar to PHP directly. But it runs in a Windows server environment. This was replaced by ASP.net. It is now replaced by ASP.NET Core. The latter two are now open source languages like PHP. I personally have never written ASP in any variant.
I would prefer ASP if I used and preferred Microsoft server. For other cases, please give me PHP. There is no comparison in the size and size of the communities.
Should I use Ruby or PHP?
Ruby, especially Ruby on Rails, was very popular over the last decade. Ruby is still a beloved language, which in my opinion is more elegant than PHP. In other words, his community is small. At the same time, I realized that Ruby is no longer the “hot language” (JavaScript has taken over that role). Ruby is elegant, and enough people are good at it that I won’t avoid it. But recruiting someone already familiar with Ruby is still harder than recruiting PHP. (Although I think the average Ruby developer is better than the same PHP developer.)
Python vs PHP: Who is better?
The last one that makes sense in a one-to-one comparison to PHP is Python. Python is used in many more scenarios than PHP, which focuses on Web development (especially statistics and analysis). And it is generally considered a more stable and elegant language.
Just like Ruby and JavaScript, Python is slightly more difficult to run on a server than PHP. But it’s a perfect language, and it’s one of the more popular languages than PHP in terms of variety of usage, I think, and everything else (e.g., various third-party libraries, acquisition of technical expertise, job hunting) is the same.
PHP vs Go? The Scala language? The Java language? , etc.
As mentioned at the outset, many languages have more or less some similarities in comparison. There are a lot of languages to compare, so just a few:
-
Java is very popular and efficient. It’s commonly used to build Android apps, desktop apps, and Web apps. However, it is not dynamically typed and has better performance guarantees, but is well suited for Web programming.
-
Go is a new language in development supported by Google. It focuses on Web services. But this is still a bit of a weakness compared to PHP (more like C), which is fast to implement but has a relatively limited community.
-
Scala** is a popular in-memory (Java-compatible) language that seems to be gaining in popularity. It’s more elegant than PHP design, but other than that, there doesn’t seem to be much more.
Again, I think this analysis is enough to make a choice, but you have more options to consider, but in the end my alternative will be PHP.
You need to choose a programming language on demand
Given the above comparison, why use PHP? I’ve already mentioned some bad design in PHP, some of which I often experience, such as in the “find type function” where needle and Haystack are not in the same order, and I still fall into the hole without code completion.
If you’re building a new Web project that doesn’t need to interact with other systems, and you’re the only one working on it, you might want to try another language, like Python. However, what you need to know is that even with a project like this, there are plenty of reasons to choose PHP.
Any modern language allows you to build a Web App. Every language has its limitations, and PHP, for example, requires a clear understanding of its limitations before you can decide whether to use it in your project. But for me, I still choose PHP to build my Web projects, as Keith Adams mentioned in his talk:
PHP development is really very efficient.
If you have a Python team, use Python. If you have a partner who is familiar with Java, use Java to write your SaaS application. Language is never the most important thing.
Wait a minute
If you’ve seen the end of this article, you’re probably interested in PHP. Maybe you’d be interested in reading some of my other content? Here’s what I wrote.
My blog: Zelin blog
My public account: PHP open-source Hub, ID: php_open