Home > headlines > body text

Why do we continue to use PHP in 2019?

不言
Release: 2019-05-03 23:17:29
forward
7149 people have browsed it

Let’s get straight to the point and say that PHP is a weird language. It's neither fast nor syntactically beautiful. Good software development practices are also not followed. But I still develop a lot of software using it. The question then becomes obvious: Why are PHP still used today?

There are many reasons besides personal idealistic preference. This is the scope of our discussion. Why 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 uses HTML tag syntax. Package code. PHP usually runs on the server side, works in conjunction with the web server, and is responsible for processing the HTML and returning it to the visitor.

PHP originally meant "Personal Home Page". Because this completely limits the meaning and desirability of using the language for general use, the language now stands for "PHP: Hypertext Preprocessor". This way of writing is called a recursive abbreviation (an abbreviation that refers to itself in the full name). Geeks love this kind of name.

What can PHP do?

#PHP What can it be used for? Generally PHP can do anything you want to implement on a web server. For example, make a blog. Implementing a SAAS application is also a piece of cake. It is also handy to write a script to temporarily process data. Or write a complex script that one day suddenly turns into a successful software business? It happened a lot in the past.

If you don’t believe me, you can take a look at the PHP official website to list usage scenarios:

Server-side script

Command line script

Writing desktop application

I don't really encourage the last one, but it does work. But the first two are really great reasons.

This leads to an important and unavoidable fact...

PHP is everywhere

Understand and love PHP There are many reasons, and perhaps the most powerful and effective reason is: it can be used and run anywhere on the network. If you look carefully, you can probably buy a hosting account for as little as $3 per month that can run Python or Ruby web applications. But it can definitely run PHP. This means you can always rely on PHP.

Because PHP can run anywhere and it is easy to use, many very popular software are written in PHP. WordPress is the most influential and familiar example to me, besides these tools like Joomla, Drupal, Magento, ExpressionEngine, vBulletin (yes, it still exists), MediaWiki, etc., they are all there PHP is running on the server.

Not only that, there are countless PHP application frameworks, such as: Symfony, Zend, Laravel, Aura, CakePHP, Yii and even the ancient CodeIgnitor framework. Of course you could make a similarly long list of web frameworks for any other language. For example, common web languages ​​like Python, Ruby, or Node/JavaScript, you can even accumulate a numerical competition list to compare with PHP. But the number of websites running PHP is overwhelming.

WordPress proudly claims to have 30% of users on the internet. You don't even need to believe this statement to realize that many Internet applications must use PHP even if this statement is even conceivably true.

Advantages of PHP

Dynamic features

PHP and HTML can work very harmoniously together. Modify file.html to file.php, you can write PHP code in the tags, and the default configuration of most web servers is to run PHP scripts directly. Precisely because the threshold is very low, novice programmers who do not need to know much programming knowledge can get started directly, resulting in a lot of low-quality code.

Because of its ease of learning, a large number of novice programmers have poured in, exposing another problem that PHP has been criticized for: PHP does not have a clear vision of being the best Web server-side language. Of course, There is no good design for this either. This led to another outcome, a loose collaboration from around the world, a hodgepodge of contributed code and ideas, and inevitably, some bad ideas seeped into it.

Having powerful object-oriented package management is now a standard in PHP

Composer is a plus for PHP.

In the development of PHP, some weird things are often released. The most famous example is the introduction of the goto statement in PHP 5.3 (widely regarded as the first modern version of PHP).

Similar problems arose during PHP's growth: object-orientation was initially implemented as a flawed and limiting concept, the standard library was filled with inconsistent names and parameter ordering, and (for example, a recently criticized Concerned chestnut) In PHP 5.3, when the :: operator is not recognized, the parser will throw a poorly readable error message: syntax error (T_PAAMAYIM_NEKUDOTAYIM). If you don’t read the documentation, you can understand this T_PAAMAYIM_NEKUDOTAYIM mark in English. What do you mean?

But now, PHP fully supports OOP. Few languages ​​have a Java-like OOP implementation like PHP. Additionally, unlike Java, PHP has a separate and widely supported package manager called Composer. It is very easy to use, and one thing that cannot be ignored is that it can easily reference high-quality and well-maintained libraries, making it very easy to use.

The rapid development of PHP

Through these facts, it is found that PHP is developing in an interesting way. It is gradually becoming a full-featured object-oriented language like Java (for better or worse), and is providing simple abstractions for functional programming, which can be said to be the current hot spot. And, there's a great set of tools being developed, and PHP loves Composer, and for good reason --- because it's done a commendable job of making some big open source projects work together.

Of course, We shouldn't forget what's hot right now: PHP's development in the PHP7 series has achieved speed improvements. This was widely believed to be caused by the emergence of HHVM on Facbook. In a short period of time, there was a risk that HHVM would develop at a pace that would destroy the PHP community, but this was not the case. Instead, PHP grew so much faster that people almost forgot about it. The existence of HHVM.

PHP has a huge community; it is newbie-friendly.

If you decide what cool new technology to use, I think what often gets little attention is the way you come to terms with the language. What is it like to learn PHP? PHP tutorials are easy to find and usually of good quality.

One of the downsides to PHP's popularity is that you'll find some not-so-good instruction from people who don't know enough about the tool. Or the “best practices” you learned from someone were ten years ago. 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.

Comparison of PHP and other languages

Next we will compare PHP with other languages. These languages ​​must meet the following requirements:

Open source: means that you can use or view the underlying language or program freely and for free; applied to the field of Web development: not necessarily focused on Web development, but has relatively large applications in Web development; high-level Dynamic language: has the characteristics of dynamic language, most languages ​​​​for web applications have this characteristic; large enough community: there are many languages ​​that meet the above conditions, but are only used in a small range, we use this last condition to filter them Lose.

Why use PHP? Instead of JavaScript?

Perhaps the most important language to compare to PHP is JavaScript. Modern development requires every project to know at least a little bit of JavaScript for client-side development and interaction. With Node, this makes using JS on the server relatively simple. It is very attractive to use the same language "isomorphically" on the server and client.

Like PHP, JavaScript is an eclectic but sometimes ugly language with many flaws and "gotchas," but JavaScript has gotten very fast in the past decade, so that's true. Why choose PHP over JavaScript? You already have expertise or use libraries in PHP. Otherwise, I think JavaScript might be a better choice.

PHP vs. Dynamic Server Pages (.Net Core)

The dynamic server language originated from a Microsoft language used for netizen programming. It is very directly similar to PHP. But it runs in a Windows server environment. This was replaced by ASP.net. Now replaced by ASP.NET Core. The latter two are now open source languages ​​like PHP. And I personally have never written a bit of ASP in any variant.

I would prefer ASP if I used and preferred Microsoft servers. Otherwise, give me PHP. The scale and size of the two communities are not comparable.

Should I use Ruby or PHP?

Ruby, especially Ruby on Rails, was very popular in the past decade. Ruby is still a much loved language and in my opinion is more elegant than PHP. That said, his community is smaller. At the same time I realized that Ruby was no longer a "hot language" (this role was taken over by JavaScript). Ruby is elegant and enough people are good at using it that I wouldn't avoid it. But recruiting people who are already familiar with Ruby is still harder than hiring 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 is meaningful in a one-to-one comparison with PHP is Python . Python has more usage scenarios than PHP, which focuses on web development (especially in data statistics and analysis). And people generally feel that it is a more stable and elegant language.

Like Ruby and JavaScript, Python is slightly more cumbersome to run on the server than PHP. But it is a very perfect language, and its use is more diverse than PHP. I think it is one of the more popular languages ​​​​than PHP, and in other aspects (such as: various third-party libraries, professional technology The acquisition of knowledge, recruitment and job hunting) are all the same.

PHP vs Go language? Scala language? Java language? Wait

As mentioned at the beginning, many languages ​​​​have more or less similarities when comparing them. There are many languages ​​​​that can be used for comparison, so I will briefly talk about a few:

java is very popular and very efficient. Usually used to build Android applications, desktop applications, and web applications. However, it is not dynamically typed, which has better performance guarantees, but is well suited for Web programming.

Go is a new language under development supported by Google. It focuses on web services. However, this area still has some shortcomings compared to PHP (more like C language). Its execution speed is very fast, but the community is relatively limited.

Scala is a popular in-memory (Java compatible) language that seems to be growing in popularity. It's more elegantly designed than PHP, but other than that, there doesn't seem to be much more to it.

Also, I think these analyzes are enough to make a choice, but there are more options you can consider, but in the end my alternative will be to consider PHP.

You need to choose a programming language according to your needs

With the above comparison, why should you use PHP? I have mentioned some bad designs in PHP above. Some of them I often experience. For example, in "Find type functions", the order of these functions needle and haystack is inconsistent. In an environment without code completion, I You will still fall into the pit.

If you are building a brand new web project, and this project does not need to interact with other systems, and you are the only one working on it, you want to try another language, like Python or something. However, what you need to know is that even for a project like this, there are many reasons for you to choose PHP.

Any modern language allows you to build a Web App. Every language has its shortcomings, such as PHP. PHP requires you to clearly understand its shortcomings before you can decide whether to use it in your project. But for me, I will still choose PHP to build my Web project, as Keith Adams mentioned in his speech:

The development efficiency of PHP is really extraordinary high.

If you have a Python team, use Python. If you have a partner who is familiar with Java, use Java to write your SaaS program. Language is never the most important thing.

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template