使用 cloud9 进行学习 php
using cloud9 for learning php
我的 class 正在学习编码。它不会超过 php,所以我正在尝试自己学习它。我们使用 jsbin 和 cloud9。 Cloud9 非常好,但我在使用它时遇到了问题。我想跟着一个特定的教程一起学习。
这是 php 的教程。 http://www.chickensmoothie.com/tutorial/tut2/index.html
我制作了一个html文件和一个php文件,代码相同。
这是代码:
<!DOCTYPE html>
<html>
<body>
<h1>My first page</h1>
<?php
//Tell the browser that we are sending it a PNG image to display
header("Content-Type: image/png");
//Echo the contents of the image file called "dogbaby.png" to send it to the browser
readfile("/images/pets/dogbaby.png");
?>
</body>
</html>
结束脚本
如果我将其保存为 html 文件,它会显示 "first page" 就好了,但在我预览网页时不会显示 php 图像。该教程明确指出,当它工作时,您应该能够看到图像,如果您看不到图像,则说明出现了问题。所以我将它保存为 php 文件。我单击相同的 运行 和预览按钮,该按钮正确显示 html 文件预览的网页。然而,它没有显示网站,而是打开一个空白页面并将文本文件下载到我的桌面。文本文件是实际的 php 文本。
有谁知道如何在 cloud9 或任何专门针对 writing/testing php 的网站中预览 php?
PHP 个文件需要由 Apache2 提供。如果您尝试在您的计算机上打开一个 PHP 文件,只需双击它就会得到同样的结果。
单击 运行 按钮以 运行 Apache 或打开终端并从那里启动 Apache。一旦 Apache 提供服务,您就可以预览 PHP 文件。
我的 class 正在学习编码。它不会超过 php,所以我正在尝试自己学习它。我们使用 jsbin 和 cloud9。 Cloud9 非常好,但我在使用它时遇到了问题。我想跟着一个特定的教程一起学习。
这是 php 的教程。 http://www.chickensmoothie.com/tutorial/tut2/index.html
我制作了一个html文件和一个php文件,代码相同。 这是代码:
<!DOCTYPE html>
<html>
<body>
<h1>My first page</h1>
<?php
//Tell the browser that we are sending it a PNG image to display
header("Content-Type: image/png");
//Echo the contents of the image file called "dogbaby.png" to send it to the browser
readfile("/images/pets/dogbaby.png");
?>
</body>
</html>
结束脚本
如果我将其保存为 html 文件,它会显示 "first page" 就好了,但在我预览网页时不会显示 php 图像。该教程明确指出,当它工作时,您应该能够看到图像,如果您看不到图像,则说明出现了问题。所以我将它保存为 php 文件。我单击相同的 运行 和预览按钮,该按钮正确显示 html 文件预览的网页。然而,它没有显示网站,而是打开一个空白页面并将文本文件下载到我的桌面。文本文件是实际的 php 文本。
有谁知道如何在 cloud9 或任何专门针对 writing/testing php 的网站中预览 php?
PHP 个文件需要由 Apache2 提供。如果您尝试在您的计算机上打开一个 PHP 文件,只需双击它就会得到同样的结果。
单击 运行 按钮以 运行 Apache 或打开终端并从那里启动 Apache。一旦 Apache 提供服务,您就可以预览 PHP 文件。