Table of Contents
My Example Form
Home headlines By 1994, I finally understood why 80% of websites were using PHP!

By 1994, I finally understood why 80% of websites were using PHP!

Nov 29, 2021 pm 02:32 PM
php

昨天晚上写代码到深夜,一头扎到床上,沉沉睡去。

第二天睁开眼镜,我发现自己居然坐在一个咖啡馆里,旁边的墙上贴着最新的英文电影海报《阿甘正传》、《肖申克的救赎》

By 1994, I finally understood why 80% of websites were using PHP!

这都是1994年的经典电影,我意识到,自己穿越到了1994年的美国!

对面坐着一个帅哥,一边操作电脑,一边在不停地赞叹。

我探过头去,发现他正在看这个东西:

By 1994, I finally understood why 80% of websites were using PHP!

我说:“哥们儿,这不是安德森开发的Mosaic浏览器吗?这么丑,你怎么不用网景?”

“网景?那是什么东西?不过兄弟不简单啊,我在咖啡馆喝了这么多天的咖啡,你是第一个识货的,还知道安德森,肯定也是个程序员吧,要不一起干吧!”

“干什么啊?”

“浏览器绝对是互联网的未来,现在很多公司都在狂热地拥抱它, 他们就使用 Microsoft Word写文档,然后将文档保存为 HTML,通过 FTP 将它们放到网上,这里边有商业机会啊。”

“写个HTML会有什么商业机会?”

“静态的网站是和枯燥的,这些公司很快就会发现,可以和用户交互的、动态的网站才有商业价值。我准备专门提供这样的咨询服务,为他们开发各种动态的Web应用程序。对了,忘了自我介绍了,我叫Rasmus Lerdorf。”

这个人名怎么这么熟悉?

我想既然穿越而来,那就看看1994年的动态网站是怎么开发的吧。

我说:“我叫张大胖,主要用Java编程。”

“Java?那是什么语言?” 他两眼立刻放光了!

我意识到说漏嘴了,Java这时候还没诞生呢!

“其实叫C++--,一个小众语言。”

“和C语言相关,那就好,我们得用C语言写CGI脚本。”

我和他合伙开了个咨询公司,专门接开发动态网站的活儿。

但是开发一开始,我就崩溃了:没有前后端分离,没有Java,没有JSP,ASP, 真的全靠在C语言!

给大家看看:

void main(int argc, char *argv[]) {
  char *params, *data, *dest, *s, *tmp;
  char *name, *age;
  puts("Content-type: text/html\r\n");
  puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>");
  puts("<BODY><h1 id="My-nbsp-Example-nbsp-Form">My Example Form</h1>");
  puts("<FORM action=\"form.cgi\" method=\"GET\">");
  puts("Name: <INPUT type=\"text\" name=\"name\">");
  puts("Age: <INPUT type=\"text\" name=\"age\">");
  puts("<BR><INPUT type=\"submit\">");
  puts("</FORM>");
  data = getenv("QUERY_STRING");
  if(data && *data) {
    params = data; dest = data;
      while(*data) {
      if(*data==&#39;+&#39;) *dest=&#39; &#39;;
      else if(*data == &#39;%&#39; && ishex(*(data+1))&&ishex(*(data+2))) {
        *dest = (char) htoi(data + 1);
        data+=2;
      } else *dest = *data;
      data++;
      dest++;
    }
    *dest = &#39;\0&#39;;
    s = strtok(params,"&");
    do {
      tmp = strchr(s,&#39;=&#39;);
      if(tmp) {
        *tmp = &#39;\0&#39;;
        if(!strcmp(s,"name")) name = tmp+1;
        else if(!strcmp(s,"age")) age = tmp+1;
      }
    } while(s=strtok(NULL,"&"));
    printf("Hi %s, you are %s years old\n",name,age);
  }
  puts("</BODY></HTML>");
}
Copy after login

用一句话来说那就是:在C语言当中输出HTML代码

这是人干的活吗?我都快写吐了!

Rasmus:“没办法啊,C语言编写CGI脚本,实现动态网页,可不就得这样嘛?对了,你会用Perl吗?”

“就是那个写出来以后代码谁都不认识的语言?我不想用!”

时间长了,Rasmus 也受不了了:“这些CGI 脚本无外乎就是处理表单, Post数据,过滤等,重复代码太多了,怎么样才能提高效率呢?”

他有空就琢磨这件事情,有一天,他想到了一招,把这些常用的功能都包装到一个C语言库中,它“植入”NCSA Web 服务器中(这是Apache之前最流行的服务器),然后在上面添加了一个模板系统,可以轻松地调用他们。

于是代码就是变成这个样子:

<html><head><title>Form Example</title></head>
<body><h1 id="My-nbsp-Example-nbsp-Form">My Example Form</h1>
<form action="form.phtml" method="POST">
Name: <input type="text" name="name">
Age: <input type="text" name="age">
<br><input type="submit">
</form>
<?if($name):?>
Hi <?echo $name?>, you are <?echo $age?> years old
<?endif?>
</body></html>
Copy after login

换句话说:就是在HTML中“混入”代码

和CGI对比,这种方式对程序员来说非常友好,我们的工作效率一下子提高了很多。

说实话,我早就知道这种方式,就是ASP,JSP嘛,但是自己没那技术实力,实现不了啊!

Rasmus 很快就找到了一个新客户,用新工具为他们开发Web程序,连接到数据库,满足他们各种各样的需求。

随着客户的增多, 客户的需求也略有不同,于是,Rasmus 就不断地扩展它的工具箱, 从简单的解析器慢慢发展为包含条件标签,然后是循环标签、函数等各种复杂的东西,这已经是一门语言了。

Rasmus 把它们称为Personal Home Page,简称PHP

我这才意识到,原来遇到了<strong>PHP之父</strong>

很快就有其他程序员找上门来, 问我们:Rasmus, 你们怎么开发得这么快!

Rasmus说:我有个人工具箱啊!

“那我能不能用?”

Rasmus说:“可以啊,工具只是我的锤子,每个人都可以用我的锤子。”

我赶忙阻止他:“Rasmus, 你把锤子给别人, 那咱们靠什么赚钱?”

“我不靠锤子赚钱,我卖的是解决问题的服务。”

我心想他真是傻瓜,为什么不靠卖他的工具来赚钱呢?学学Bill Gates,过几年上市!

让我没想到的是,神奇的事情发生了。

People who use PHP started sending patches to Rasmus - they found bugs that Rasmus didn't even find!

So Rasmus went to the customer and said: I upgraded to a new version, changed this, changed that.

Customers are very satisfied. They think our work efficiency is very high, not only can we complete functions quickly, but we can also quickly fix bugs.

I suddenly realized: Isn’t this open source?

Of course, this was 1994 or 1995, and the term open source had not yet appeared. At that time, there was only free software advocated by RMS.

As more and more people submitted patches, PHP gradually improved. In 1995, Rasmus saw that the time was ripe and officially announced the birth of PHP 1.0.

By 1994, I finally understood why 80% of websites were using PHP!

So this is how PHP started!

Rasmus showed the generosity and style of a leader when he gave up exclusive control of PHP.

By giving ownership of the project to others so that everyone can contribute, PHP becomes everyone's project, not Rasmus's alone.

At that time, the PHP source code was placed in CVS. I wanted Rasmus to put the PHP source code on GitHub. But at that time, there was not even Git. Where did the Hub come from?

There is no management here. Everyone is a small self-organized group. They can self-organize around what they are interested in.

Appoint people on their merits and let the code speak for itself.

This really changes the nature of PHP.

One weekend, Rasmus and I came to the cafe for coffee again, and I said: "I think you need to add some advanced features to PHP!"

"For example, generics, annotations , Function-oriented programming, Lambda and the like."

"No, no, I hopeto control the threshold for entering PHP at a very low level, whether using it or contributing to it. Anyone who wants to solve a web problem will usually find a very straightforward solution through PHP. Many of the alternatives that claim to solve web problems are too complex. Think about it. You have until Friday to get the job done, but you have to flip through 800 pages of it. Manual, this is frustrating."

"Have you ever thought that PHP will dominate the Web in the future?"

"Haha, is this possible?"

Little did Rasmus know at the time that PHP would grow wildly in the Internet tide, marrying Linux, MySQL, and Apache, and constantly conquering cities and territories.

W3Tech statistics show that PHP dominates the Web, with nearly 80% of websites using PHP!

By 1994, I finally understood why 80% of websites were using PHP!

"If you were asked to summarize how to create a successful open source project, what would you say?"

When talking about this topic, Rasmus suddenly He started talking non-stop, because he developed a project from 0 to 1, so he had so much say!

If you only have one cool idea, no one will join your project, everyone has cool ideas.

If you Create something that's half-baked, and people will probably turn their noses up at what you're doing, and they'll go their own way to solve the problem.

Only if you build something useful enough, People will come to you, they'll be more receptive to your code, and then extend it a little to solve their own problems, and then the snowball will start rolling.

So, be To start an open source project, you have to solve a problem that has been bothering you for a while. It may take months to find the real problem and solve it. Then you have to accept the advice of early adopters and do your best to make the tool more useful for the future. A broad audience helps.

Finally consider giving up control and letting others work with you. When people do whatever they want with your code, your The open source project was successful!

“That’s great, I hope all my readers can see this paragraph.”

“Your readers?”

"Yes, the coder turned over the headlines, I can't say too much, the secret must not be leaked, I have to leave."

After saying that, I disappeared.

Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1262
29
C# Tutorial
1235
24
How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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.

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

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

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

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