search
HomeBackend DevelopmentPHP TutorialPHP 语言急需避免的 10 大误区

PHP 语言需要避免的 10 大误区

  PHP是一种非常流行的开源服务器端脚本语言,你在万维网看到的大多数网站都是使用php开发的。但是,你大概很奇怪的注意到有少部分的人发誓要离php 远远的。但是令人更奇怪的是或者很震惊的说他们不用php是因为一些被证实的语言缺点。他们决定不用php,是基于误解。

  是的,你读到的那些是误解。

  让我们看看这些误解是:

  1. PHP是一种面向对象语言,但面向对象并不彻底

  这完全不对。所有认为php不是彻底面向对象的程序员,尤其是Java程序员,都需要上一个PHP的基础培训;他们会发现PHP中大量面向对象的特性。例 如:接口、方法、抽象类等等。我同意早期的PHP版本确实不支持太多面向对象的特性,但PHP5已经有强大的面向对象支持。而且,你一定想不到编码在 PHP中会变得如此简单,那是因为PHP和面向对象结合的原因。

  所以,消除这个误解吧。

  2.PHP无法实现特定功能

  我很清楚这种表述很含糊,但是我不能想出任何更好的说法。这是一个很含糊的误解,开发人员认为PHP不能帮助他们实现一些诸如内存访问的功能或者一些 PHP主要发行版没有提供支持的功能。但事实是PHP是一种可扩展的语言,所以你需要做的是用C或者C++编码,然后创建对应的扩展。

  其实,你根本不需要自己动手去创建扩展,因为这里已经有数以百计的可用扩展。你唯一需要做的就是去寻找它们。

  3.PHP 是不安全的

  开发者对PHP的另外一个误解就是PHP网站和 应用是不安全的。但是,为什么你会希望它在默认情况下是安全,为什么不编写安全的代码? 我知道这里一直存在很多不安全的PHP代码,因为最初的学习曲线是简单的而且很容易上手。所以,作为一个开发者,你需要使它尽可能的安全。

  .Net可以帮助你在默认情况下是安全的,相比之下PHP确实缺少很多。但是如果你是一个训练有素的程序员,那么你其实不要默认情况的安全帮助。Include通常是安全的,但是你需要要小心。如果它们的路径是动态生成的,对指令的透彻理解可以帮助你让代码更安全。

  4. 它不能适应大型应用

  大型复杂应用需要建立在自身可靠和高性能的语言之上,这是PHP在一定程度上所没有的。但是,如果你设计和开发的应用程序架构稳定,为什么你会对它的性能和可扩展性有疑问呢?

  事实上一些顶尖网站,如Facebook、维基百科和雅虎等等,都是基于PHP构建的,就像我们所想的那样,这些巨型网站都工作的很好。

  5. PHP只能用于网站开发

  这也是一个误解,尽管看起来它有点合乎逻辑,因为PHP是网站开发中最常见的语言。但也有一些被称为命令行界面的东西,这可以确保你的PHP应用程序可以在Web服务器之外运行。

  你可能不相信,但即使是那些很大程度上取决于CPU能力的应用程序,也可以用PHP开发的,使用PHP CLI来运行。

  更重要的是,如果你想使用PHP开发桌面应用程序,不用担心,使用Windows特定扩展你可以做到这一点。

  6.开发过程慢

  这是一直广为流传的误解。我不知道起源于何处?这个流言可能来自于曾经一个时期php代码很乱并且代码中四处充斥着Mysql语句(他们以此为反例,但是 实际上我们都不这样用)。问题是为什么这样开发过程就慢了?当大量的php框架出现时,可以大大的加速开发的过程。毋庸置疑,你可以在短时间内开发出很大 的程序,不论它有多么的复杂。所以,你用php开发一点都不慢,特别是当你使用php框架的时候。

  7.专业开发人员不使用PHP

  PHP是针对初学者的,它是为那些不是认认真真做开发的人设计的。这些说法都和PHP的使用有关。这只是一种误解,认同它没有任何意义。这里有如此多的网络应用,包括一些大型的,都是使用PHP构建的。可以想象这些说法是多么不正确。

 

  8. 性能问题

  这是一个棘手问题。这不是一个误解。和硬币有两个面一样,这个问题也是两方面的。事实上到处充斥着垃圾代码,隐式转换、不适用的模块、缺少操作符重载等等都能影响一个php应用的性能。但是这个依赖于你是不是有足够的能力去用好这个语言,用它编写稳定地、快速地应用。

  性能是由你设计的架构和你写的代码来决定的!

  9. 便宜没好货

  这条貌似在逻辑上很站得住脚,但是用到php上那就是完全是误解了!事实上,php的最大优势就是他的免费和开源,这意味着大多数提供应用开发服务的开发 者必须都精通它。虽然免费开源会带来一定问题,但是这也为了使用他们服务的客户提供成本优势。与商业开发语言相比较,php的开发成本比价低,但是这并非 意味着它的质量值得怀疑。和正确的开发者一起工作,可以获得更高性能的php应用。

  10. PHP言过其实

  真是这样么?你随口瞎说的吧。我不认为这样,还有很多的开发者也都不这样认为。

  结束语

  这不是所有php谎言的终结者。随着php语言不断的发展,变得越来与强大,误解也会跟着增长的。但请不要被他们忽悠了。多读,多问,自己动动手,然后你就知道,是不是真的了。

  英文原文:PHP Language – Top 10 Misconceptions to Avoid

Statement
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool