
原文来自 Coding Duck
这个系列是“入门”用的,看看各种语言如何写Hello World
这一篇先来PHP的
- 打开
terminal
terminal 在你的电脑里叫“终端”或者“命令行”
- 找个路径建个目录
$ mkdir php
- 进入这个目录
$ cd php
- 在这个目录下新建一个
index.php,里面的代码是这样的
<?php
echo "hello world !";
- 保存一下,然后就写完代码了
- 回到你的terminal,进入你刚才的路径
php index.php
- 激动人心的时刻就要到了,开启一下服务吧
php -S 0.0.0.0:8080
- 然后你的应该出现一堆很神奇的东西
PHP 5.5.30 Development Server started at Thu Jan 21 12:49:35 2016
Listening on http://0.0.0.0:8080
Document root is /Users/Echo/php
Press Ctrl-C to quit.
-
这个时候打开你的浏览器,在地址栏输入 http://127.0.0.1:8080
-
hello world !出现了。
####收工