如果PHP是用英式英语编写的
PHP之父Rasmus Lerdorf在创造出PHP时,他并没有用格陵兰语或者丹麦语编写(尽管他有格陵兰和丹麦血统),这是非常明智的。虽然对他来说用英语编写,并没有用自己母语编写来得容易。由于他以前在加拿大待过,所以他选择了本地方言。不是法语,也不是不合纯正英语标准的方言,我们通常称其为“美式英语”。
从那以后,英国的PHP开发人员就对这件事情格外不满。Rasmus在想什么?更重要的是,我们要如何改变这个既成的事实?我们开发人员如何保证即使在数字时代,大英帝国的优良传统也能继续发扬光大?
一记耳光
$variable_name 最有必要更改就是要删除一些深受美国人喜欢的符号,并用一些更加精炼的符号代替,让PHP变得更加优雅。
?variable_name 开始吧
今天的英国程序员中,有多少人一开始接触到的就是“Hello World”这个典型的美国式程序,虽然简单但老套粗俗令人反感?一份更加冠冕正式的介绍将会促进大部分年轻的英国天才使用这种语言,从而为更广阔的用户群提供更加文雅的气氛。
缩写词
没有东西比没必要的缩写词更加让英国人痛恨的。“缩写词”在伦敦的街道上闻所未闻,正如土生土长的英国文法家不肯自降身份去发送“c u soon traffic kthxbye”等各种信息,宁愿使用一些看起来更加文雅的词句代替:“亲爱的先生或女士。只要时间允许,我希望在一个小时之内,尽快到达。我向各位保证,你们的马匹会得到妥善安置。敬上。”(输入较慢,是的,但是不至于仓促)。
从另一方面来说,PHP里面包含很多毫无必要的缩写字和缩写字首字母。
str_replace() is_int() var_dump() preg_match() json_encode() mysql_connect() 应该改成下面这样:
string_replace() is_integer() variable_dump() perl_regular_expression_match() javascript_object_notation_encode() my_structured_query_language_connect() 校正:我已经更正了“preg_match”的扩充——感谢指出来的朋友。
口才
if ($condition) { // Code here } else { // Code here } 莎士比亚可不愿意看到他的母语被扭曲成这个怪物。简练在适当的场合很受欢迎——在一些偏僻的地方未必如此——但不是这里。“if … else”模块是PHP之中用得最多的条件代码,所以它在使用时必须是尽可能的安全无害。有很多选择可以取代,但是这个条件语句也许是最稳健的。
perchance (?condition) { // Code here } otherwise { // Code here } 上述模块同样适用于美国化的,只能说是笨重的,让人厌恶的switch … case概念,
switch ($variable) { case $option1: //Code here break; case $option2: //Code here break; default: //Code here break; } 像”switch”, “break” and “default”这样的关键字对读者来说很有难度并且缺乏联系。这种美式用法真是需要改进。(使用美式用法的人有一些有趣的想法,期望用i_might_be_partial_to()这样的语句来代替include()来显示他们天才的编程天赋):
what_about (?variable) { perhaps ?possibility: //Code here splendid; perhaps ?other_possibility: //Code here splendid; on_the_off_chance: //Code here splendid; } 拼写
imagecolorallocate() serialize() newt_centered_window() connection_status() 在这点上,单词让我吃过不少亏。自重的绅士期待该如何看得懂这些“单词”。它削弱了任何人接受编程语言中单词的曲解含义的信念。这些“单词”和众多相似的错误,应该立即恢复到适当的形式。
imagecolourallocate() serialise() newt_centred_window() connexion_status() 习惯
try { // Code here } catch (Exception $e) { // Handle exception die('Message'); } try … catch语句块是PHP缺乏特点的一个很好证明。新的PHP过于直接地允许使用该模块http://www.gw005.com ,缺乏应有的限制。另外,单词“die”很让人丧气。这个新模块,尽管更加冗长,但更为文雅和乐观。
would_you_mind { // Code here } actually_i_do_mind (Exception ?e) { // Politely move on cheerio('Message'); } 类
在英国人的心里,没有什么东西跟类的概念一样重要和根深蒂固,而且,PHP当中的这一部分很少变动,除非是这里做出的重要更改。
class Republic { public $a; private $b; protected $c; } $example = new Republic; 首先,流行的系统中并没有类层次存在的余地,这是无法接受的。所以我们首先应该赋予类的特定等级——上层,中层,工作层(upper, middle, working )——如果没有更高等级指令类的明确许可,类就无法使用一个更高级的类的方法(当然,即使它后来已经访问了更高级的类,但它并非更高级指令的正式成员,无法授予自身访问其他低级别指令类的更高级指令)。“public”和“private”,在英国人的类系统中是同义词(例如,学校制度命名),所以这些必须进行调整,“protected”的属性可见性也一样。单词“new”,虽然可行,但在类问题上需要有一个更加恰当的词来代替。
upper_class Empire { state ?a; private ?b; hereditary ?c; } ?example = nouveau Empire; 日不落…
希望这些少数简单的变动能够提升PHP在众多编程语言之中的声誉和地位。它不再是蹩脚美国人的远亲。相反,它能重新回到作为脚本语言之王的英国人的怀抱中。
注:原文作者Dave是一位英国开发人员。

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.


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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use