为什么说PHP是个集中营
有一天我跟在DUMBO
的一个非常棒的创业公司
的老板聊天,谈到为什么非PHP界的开发人员普遍轻视PHP和PHP相关社区。他提出了一个观点让我印象很深,很大程度上是因为以前从来没有听到过这样的说法。 如果你不知道大多数的程序员都会对PHP发什么样的牢骚,那么,这些牢骚差不多会像这样: 但他所说的PHP的问题却是另外一个问题。他并没有说这种语言有问题――他认为这种语言被一种常见的文化现象包围着,是一种通常由语言的创造者造就的文化传统,现在看来这对一些糟糕的编程实践方法起到了鼓励作用。也就是它使PHP代码变的劣质和不可维护。 这种一个语言或框架上体现出创始人的哲学思想并被相关社区推崇的现象是的确存在的。他拿出来Ruby和其创始人Matz
作为例子。Matz想要的是一种易读易写、能提高程序员工作效率的语言。没看见Ruby开发人员们言之必称快速开发以及这种语言的优雅? 接着就是DHH
?
和他的Rails框架。还有Guido
和他的Python语言。于是我在想:Rasmus
对于PHP呢? Rasmus Lerdorf给人的印象非常的有趣。他创建了最初版的PHP语言,而且一直在改进这种语言,他在PHP社区里被当作神一样崇拜,他在PHP的任何方面都享有最大的权威。他被众多的会议邀请
去做演讲,同时被大网络公司所雇用
,他获得了所有人的尊敬――尽管有这样一种事实:他成了大多数的非PHP程序员所鄙视的PHP上的众多问题的形象代表。 Rasmus倡导避免使用框架,而把PHP更多的当作一种模板语言。对他来说,这种做法能产生直接的运行效率和可扩展性(程序负载可知)。而对于其他的所有人来说,这种做法导致了大量的乱炖似的过程式代码,大量的无法维护的项目。自从1995年PHP诞生至今大概10年左右的时间里,所有的PHP项目都是按照这种指导写成的。 与此同时另外一个问题突然的出现了:在PHP5.0之前,PHP的初期,PHP获得了大量的新手的追随。这种语言的入门门槛出奇的低,任何人都可以下载自解压的×AMP Windows程序安装包、在2两分钟内用上这种语言。除此之外,那时在web开发方式上对MVC模式的共识并没有真正的出现。这样一来你可以想象,一群新手和一个缺乏好的开发实践方法的语言组合到一起能创造出什么?一堆无法维护的垃圾。而且整个大环境都是这样。 不要误解我的话――优秀的PHP开发者还是不少的,即使是当时。但是,就像我说的,粗制滥造的菜鸟作品到处都是。当牛仔式无羁的PHP程序员在没有指导原则的情况下聚集到一起开发程序,于是像PHPbb、 PHPNuke以及很多的粗糙的.php3程序包就出现了。但是你能单纯的责怪PHP开发人员吗?不能!其它的web语言巨人,ASP和Perl,同样恶名远扬,同样宣传着一种乱炖式的开发方式。 所以这就是为什么PHP会得到这样的骂名。是因为它的历史流传。大多数已经转向Python,Ruby和Java的当年的PHP开发人员并没有在web上MVC概念兴起时回头去重新思考这种语言。此外,更有一些像”Ruby公子“Zed Shaw抱怨一些程序员的思想”受PHP毒害“这样的露骨的讽刺,像这样的言论在RubyInside上很盛行
。 PHP是个集中营
但像Zend和CodeIgniter这样的框架的出现把这种语言推向了正确的开发方向上。事实上,它把PHP推向了与Rasmus所希望看到的相反的方向上了。查看一下Zend和CodeIgniter框架,你会发现它们是为数不多的文档写的很好,代码写的很好的程序。 大多数学习了Ruby开发人员同时都要学习Rails和MVC知识;PHP在此之前已经被使用了整整10年。对于那些新手来说可恶的Ruby没有给他们这段时间让他们自由发挥。Rails有现成的标准指导,它的入门门槛相对高很多,通常会把一些缺少经验的开发人员挡在门外。 事实上,PHP应用程序是可以向其它种语言那样写的很好,而且还会具有一定的运行速度上的优势。PHP世界里的MVC风格的开发方法兴起只是在近几年才出现的现象。不得不承认,我们应该感谢Rails带来的这种变化。 那么,PHP如今是个什么样呢? 除此之外,互联网上大多数有影响的网站都使用PHP作为它们后台的语言或工具,诸如Facebook,Digg,维基百科,Wordpress,Drupal等等。我相信,对PHP有一个深入的掌握会使一个程序员打开更多的未知领域的大门。 如果你不赞同上面所说的,请留下评论,或email给我――我想听听你为什么不这么认为。 事实上,我并不是一个PHP迷,我对语言没有感觉。我使用PHP大多是因为――你猜到了――有人愿意付钱给我。所以一切归咎于此: 如果你希望在软件设计上做出明智的决定,PHP是你开发web应用程序的最佳选择。
顺便说一下,如果你确信要使用PHP来开发下一个web应用,请试一试CodeIgniter
。它是一个轻量级的,普通的,超级快的PHP框架。对于CodeIgniter,我是个粉丝。 ? :)

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.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

Key players in HTTP cache headers include Cache-Control, ETag, and Last-Modified. 1.Cache-Control is used to control caching policies. Example: Cache-Control:max-age=3600,public. 2. ETag verifies resource changes through unique identifiers, example: ETag: "686897696a7c876b7e". 3.Last-Modified indicates the resource's last modification time, example: Last-Modified:Wed,21Oct201507:28:00GMT.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
我也喜欢CodeIgniter,目前正在学习。
感觉一个语言的劣势,光靠框架是难以弥补的. 所以现在非常坚定地追随python和c#. 二者都非常牛叉优雅,并且几乎可以用在不同的场合. IronPython和C#可以互相调用! 当我知道这一点的时候, 兴奋之情难以言表. 你说,c#和python合璧, 有啥项目做不出来? 还有啥项目是难做的?
所以说啊, php框架的粉丝们,苦海无涯,回头是岸... 有比php更好的东西,并且多着呢.
感觉一个语言的劣势,光靠框架是难以弥补的. 所以现在非常坚定地追随python和c#. 二者都非常牛叉优雅,并且几乎可以用在不同的场合. IronPython和C#可以互相调用! 当我知道这一点的时候, 兴奋之情难以言表. 你说,c#和python合璧, 有啥项目做不出来? 还有啥项目是难做的?
所以说啊, php框架的粉丝们,苦海无涯,回头是岸... 有比php更好的东西,并且多着呢.
symfony框架很不怎么样。现在的框架我感觉还是yii不错,codeigniter没用过,但与yii相比,速度挺慢的,zendframework速度更慢,且过度设计了,严重不推荐。我熟悉python,以及django,感觉做网站还是php好,当然首先要选一个好框架,并花点时间学会它。
PHP目前最大的悲哀就是没有好的框架。有一些有标准的东西。比如:log4php,那是抄的JAVA的。CAKE,那是抄的ROR的。可悲的是抄的人,根不并不精通PHP。所以,也是垃圾。