search
HomeheadlinesBy 1994, I finally understood why 80% of websites were using 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>");
}

用一句话来说那就是:在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>

换句话说:就是在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
This article is reproduced at:码农翻身. If there is any infringement, please contact admin@php.cn delete
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft