If PHP is a _ PHP Tutorial written in English

Source: Internet
Author: User
If PHP is written in English. RasmusLerdorf, the father of PHP, was wise when he created PHP and did not write it in plain or Danish (although he has Greenland and Danish. Although it was wise for him to use Rasmus Lerdorf, the father of PHP, to create PHP, he did not write it in plain or Danish (although he has Greenland and Denmark. It is not easy for him to write in English. He used to be in Canada, so he chose a local dialect. It is neither French nor pure english. we usually call it "American English ".

Since then, PHP developers in the UK have been particularly dissatisfied with this issue. What is Rasmus thinking? More importantly, how should we change this fact? How can our developers ensure that even in the digital age, the fine traditions of the British Empire can continue to flourish?

A slap in the face

 
 
  1. $variable_name

The most necessary change is to delete some symbols favored by Americans and replace them with more refined symbols to make PHP more elegant.

 
 
  1. £variable_name

Let's get started.

 
 
  1. echo 'Hello World!';
  2. ?>

How many of today's British programmers are initially exposed to the typical American program "Hello World", which is simple but vulgar? A more formal introduction will promote the use of this language by most young British talents, so as to provide a more elegant atmosphere for a wider user base.

 
 
  1. announce 'Good morrow, fellow subjects of the Crown.';
  2. ?>

Acronyms

There is nothing that the British hate more than unnecessary acronyms. "Acronyms" are unheard of on the streets of London, just as local British grammar writers refuse to send "c u soon traffic kthxbye" and other information by downgrading their identities, I would rather use words that look more elegant than: "Dear Sir or Madam. As long as time permits, I hope to arrive within an hour as soon as possible. I assure you that your horses will be properly placed. ." (The input is slow, yes, but not in a rush ).

On the other hand, PHP contains many unnecessary abbreviations and acronyms.

 
 
  1. str_replace()
  2. is_int()
  3. var_dump()
  4. preg_match()
  5. json_encode()
  6. mysql_connect()

It should be changed to the following:

 
 
  1. string_replace()
  2. is_integer()
  3. variable_dump()
  4. perl_regular_expression_match()
  5. javascript_object_notation_encode()
  6. my_structured_query_language_connect()

Correction: I have corrected the expansion of "preg_match"-thanks to the friends who pointed out.

Eloquence

 
 
  1. if ($condition) {
  2. // Code here
  3. } else {
  4. // Code here
  5. }

Shakespeare does not want to see his mother tongue distorted into this monster. Concise and popular in proper scenarios-not necessarily in some remote places-but not here. "If... The else module is the most commonly used conditional code in PHP, so it must be as safe and harmless as possible during use. There are many options to replace, but this condition statement may be the most robust.

 
 
  1. perchance (£condition) {
  2. // Code here
  3. } otherwise {
  4. // Code here
  5. }

The above modules are also applicable to the United States. they can only be said to be heavy and annoying switches... Case concept,

 
 
  1. switch ($variable) {
  2. case $option1:
  3. //Code here
  4. break;
  5. case $option2:
  6. //Code here
  7. break;
  8. default:
  9. //Code here
  10. break;
  11. }

Keywords such as "switch", "break", and "default" are difficult for readers and lack of contact. This kind of American usage really needs to be improved. (People who use the American style have some interesting ideas and expect to use statements like I _might_be_partial_to () instead of include () to show their talented programming talents ):

 
 
  1. what_about (£variable) {
  2. perhaps £possibility:
  3. //Code here
  4. splendid;
  5. perhaps £other_possibility:
  6. //Code here
  7. splendid;
  8. on_the_off_chance:
  9. //Code here
  10. splendid;
  11. }

Spelling

 
 
  1. imagecolorallocate()
  2. serialize()
  3. newt_centered_window()
  4. connection_status()

At this point, words have made me suffer a lot of losses. A self-respecting gentleman looks forward to understanding these "words ". It weakens the belief that anyone accepts the misinterpretation of words in programming languages. These "words" and similar errors should be immediately restored to the appropriate form.

 
 
  1. imagecolourallocate()
  2. serialise()
  3. newt_centred_window()
  4. connexion_status()

Habits

 
 
  1. try {
  2. // Code here
  3. } catch (Exception $e) {
  4. // Handle exception
  5. die('Message');
  6. }

Try... Catch block is a good proof of PHP's lack of features. The new PHP is too direct to allow the use of this module, lack of restrictions. In addition, the word "die" is frustrating. This new module is more lengthy, but more elegant and optimistic.

 
 
  1. would_you_mind {
  2. // Code here
  3. } actually_i_do_mind (Exception £e) {
  4. // Politely move on
  5. cheerio('Message');
  6. }

Class

In the British mind, nothing is as important and deep-rooted as the concept of classes, and this part of PHP rarely changes unless it is an important change made here.

 
 
  1. class Republic {
  2. public $a;
  3. private $b;
  4. protected $c;
  5. }
  6. $example = new Republic;

First, there is no room for class hierarchy in popular systems, which is unacceptable. Therefore, we should first assign a specific class level-upper, middle, and working layer (upper, middle, and working)-If there is no explicit permission for the higher-level instruction class, the class cannot use a more advanced class method (of course, even if it has accessed a more advanced class later, it is not a formal member of a more advanced instruction, you cannot authorize yourself to access more advanced commands of other low-level instruction classes ). "Public" and "private" are synonyms in British class systems (for example, school naming), so these must be adjusted, and "protected" has the same attribute visibility. Although the word "new" is feasible, there must be a more appropriate word to replace it in terms of class issues.

 
 
  1. upper_class Empire {
  2. state £a;
  3. private £b;
  4. hereditary £c;
  5. }
  6. £example = nouveau Empire;

Day by day...

It is hoped that these few simple changes will improve the reputation and position of PHP in many programming languages. It is no longer a bad American distant friend. Instead, it can return to the British who are the king of scripting.

Original English:

Rasmus Lerdorf, the father of http://www.bkjia.com/PHPjc/445711.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445711.htmlTechArticlePHP, was wise to create PHP and he did not write it in plain or Danish (although he has Greenland and Danish. Although he is using English...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.