If PHP was written in British English_PHP Tutorial
Rasmus Lerdorf, the father of PHP, was very wise when he created PHP not in Greenlandic or Danish (although he has Greenlandic and Danish ancestry). Although writing in English is not as easy for him as writing in his native language. Since he had spent time in Canada before, he chose the local dialect. It’s not French, nor is it a dialect that doesn’t conform to the standard of pure English, which we usually call “American English.”
Since then, British PHP developers have been particularly dissatisfied with this matter. What was Rasmus thinking? More importantly, how do we change this fait accompli? How do we developers ensure that the fine traditions of the British Empire continue to flourish even in the digital age?
One note Slap
<ol class="dp-xml"><li class="alt"><span><span>$variable_name </span></span></li></ol>
The most necessary change is to delete some symbols that are loved by Americans and replace them with some more refined symbols to make PHP more elegant.
<ol class="dp-c"><li class="alt"><span><span>£variable_name </span></span></li></ol>
Let’s get started
<ol class="dp-xml"><li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>echo 'Hello World!'; </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li></ol>
How many of today’s British programmers were first exposed to the typical American “Hello World” program, simple but offensively old-fashioned and vulgar? A more formal introduction would promote the use of the language by most of the young British geniuses, thus providing a more urbane atmosphere to a wider user base.
<ol class="dp-xml"><li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>announce 'Good morrow, fellow subjects of the Crown.'; </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li></ol>
Acronyms
There is nothing the British hate more than unnecessary abbreviations. "Abbreviations" were unheard of on the streets of London, just as the native English grammarian refused to deign to send "c u soon traffic kthxbye" and other messages, preferring to use some more elegant-looking phrases instead: "Dear Sir or ma'am. I hope to arrive as soon as possible, within an hour. I assure you that your horses will be well accommodated." (Slower input, yes, but not in a hurry).
On the other hand, PHP contains a lot of unnecessary abbreviations and acronyms.
<ol class="dp-xml"> <li class="alt"><span><span>str_replace() </span></span></li> <li><span>is_int() </span></li> <li class="alt"><span>var_dump() </span></li> <li><span>preg_match() </span></li> <li class="alt"><span>json_encode() </span></li> <li><span>mysql_connect() </span></li> </ol>
should be changed to the following:
<ol class="dp-xml"> <li class="alt"><span><span>string_replace() </span></span></li> <li><span>is_integer() </span></li> <li class="alt"><span>variable_dump() </span></li> <li><span>perl_regular_expression_match() </span></li> <li class="alt"><span>javascript_object_notation_encode() </span></li> <li><span>my_structured_query_language_connect() </span></li> </ol>
Correction: I have corrected the expansion of "preg_match" - thanks to the friend who pointed it out.
Eloquence
<ol class="dp-c"> <li class="alt"><span><span class="keyword">if</span><span> (</span><span class="vars">$condition</span><span>) { </span></span></li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"> <span>} </span><span class="keyword">else</span><span> { </span> </li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"><span>} </span></li> </ol>
Shakespeare would not have liked to see his native language twisted into this monster. Simplicity is popular in the right circumstances - not necessarily in some remote places - but not here. The "if ... else" module is the most commonly used conditional code in PHP, so it must be as safe and harmless as possible when used. There are many alternatives, but this conditional statement is perhaps the most robust.
<ol class="dp-c"> <li class="alt"><span><span>perchance (£condition) { </span></span></li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"><span>} otherwise { </span></li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"><span>} </span></li> </ol>
The above modules are also suitable for Americanized, which can only be said to be bulky and disgusting switch... case concepts,
<ol class="dp-c"> <li class="alt"><span><span class="keyword">switch</span><span> (</span><span class="vars">$variable</span><span>) { </span></span></li> <li> <span> </span><span class="keyword">case</span><span> </span><span class="vars">$option1</span><span>: </span> </li> <li class="alt"> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li> <span> </span><span class="keyword">break</span><span>; </span> </li> <li class="alt"> <span> </span><span class="keyword">case</span><span> </span><span class="vars">$option2</span><span>: </span> </li> <li> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li class="alt"> <span> </span><span class="keyword">break</span><span>; </span> </li> <li> <span> </span><span class="keyword">default</span><span>: </span> </li> <li class="alt"> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li> <span> </span><span class="keyword">break</span><span>; </span> </li> <li class="alt"><span>} </span></li> </ol>
like "switch", "break" Keywords like ” and “default” are difficult for readers and lack connection. This American usage really needs improvement. (People who use American usage have some interesting ideas and hope to use statements like i_might_be_partial_to() instead of include() to show their programming genius):
<ol class="dp-c"> <li class="alt"><span><span>what_about (£variable) { </span></span></li> <li><span> perhaps £possibility: </span></li> <li class="alt"> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li><span> splendid; </span></li> <li class="alt"><span> perhaps £other_possibility: </span></li> <li> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li class="alt"><span> splendid; </span></li> <li><span> on_the_off_chance: </span></li> <li class="alt"> <span> </span><span class="comment">//Code here </span><span> </span> </li> <li><span> splendid; </span></li> <li class="alt"><span>} </span></li> </ol>
Spelling
<ol class="dp-c"> <li class="alt"><span><span>imagecolorallocate() </span></span></li> <li><span>serialize() </span></li> <li class="alt"><span>newt_centered_window() </span></li> <li><span>connection_status() </span></li> </ol>
At this point, words have made me suffer a lot. How can a self-respecting gentleman understand these "words"? It undermines anyone's belief in accepting the distorted meanings of words in programming languages. These "words," and numerous similar errors, should be immediately restored to their proper form.
<ol class="dp-c"> <li class="alt"><span><span>imagecolourallocate() </span></span></li> <li><span>serialise() </span></li> <li class="alt"><span>newt_centred_window() </span></li> <li><span>connexion_status() </span></li> </ol>
Habit
<ol class="dp-c"> <li class="alt"><span><span>try { </span></span></li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"> <span>} catch (Exception </span><span class="vars">$e</span><span>) { </span> </li> <li> <span> </span><span class="comment">// Handle exception </span><span> </span> </li> <li class="alt"> <span> </span><span class="keyword">die</span><span>(</span><span class="string">'Message'</span><span>); </span> </li> <li><span>} </span></li> </ol>
try … catch block is a good example of PHP’s lack of features. The new PHP allows the use of this module too directly and lacks the restrictions it should have. Also, the word "die" is very depressing. This new module, although more lengthy, is more elegant and upbeat.
<ol class="dp-c"> <li class="alt"><span><span>would_you_mind { </span></span></li> <li> <span> </span><span class="comment">// Code here </span><span> </span> </li> <li class="alt"><span>} actually_i_do_mind (Exception £e) { </span></li> <li> <span> </span><span class="comment">// Politely move on </span><span> </span> </li> <li class="alt"> <span> cheerio(</span><span class="string">'Message'</span><span>); </span> </li> <li><span>} </span></li> </ol>
Classes
In the hearts of British people, nothing is as important and deep-rooted as the concept of classes, and this part of PHP rarely changes , unless there are important changes made here.
<ol class="dp-c"> <li class="alt"><span><span class="keyword">class</span><span> Republic { </span></span></li> <li> <span> </span><span class="keyword">public</span><span> </span><span class="vars">$a</span><span>; </span> </li> <li class="alt"> <span> </span><span class="keyword">private</span><span> </span><span class="vars">$b</span><span>; </span> </li> <li> <span> </span><span class="keyword">protected</span><span> </span><span class="vars">$c</span><span>; </span> </li> <li class="alt"><span>} </span></li> <li> <span class="vars">$example</span><span> = </span><span class="keyword">new</span><span> Republic; </span> </li> </ol>
First of all, there is no room for class hierarchy in popular systems, which is unacceptable. So we should first give the class a specific level - upper, middle, working - so that the class cannot use the methods of a higher-level class without explicit permission from the higher-level directive class (of course , even if it has subsequently accessed a higher-level class, it is not a formal member of the higher-level directive and cannot grant itself access to higher-level directives of other lower-level directive classes). "public" and "private" are synonymous in the British class system (e.g., school system naming), so these must be adjusted, as is the property visibility of "protected". The word "new", while feasible, needs to be replaced by a more appropriate word in class problems.
<ol class="dp-c"> <li class="alt"><span><span>upper_class Empire { </span></span></li> <li><span> state £a; </span></li> <li class="alt"> <span> </span><span class="keyword">private</span><span> £b; </span> </li> <li><span> hereditary £c; </span></li> <li class="alt"><span>} </span></li> <li><span>£example = nouveau Empire; </span></li> </ol>
The sun never sets...
Hope these few simple changes can enhance PHP's reputation and status among many programming languages. It’s no longer a distant relative of crappy Americana. Instead, it falls back into the lap of the British as kings of scripting languages.
English original text:

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

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
