使用 Cloud9 学习 PHP


using cloud9 for learning php

我的课正在学习编码。它不会超过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 文件,它可以很好地显示"第一页",但在预览网页时不会显示 php 图像。 该教程明确指出,当它工作时,您应该能够看到图像,如果您没有看到图像,则它出错了。所以后来我把它保存为一个php文件。我单击了相同的运行和预览按钮,该按钮正确显示网页以进行 html 文件的预览。然而,它不是显示网站,而是打开一个空白页面并将文本文件下载到我的桌面。文本文件是实际的 PHP 文本。

有谁知道如何在Cloud9或任何专门用于编写/测试PHP的网站中预览PHP?

PHP文件需要与Apache2一起提供。如果您尝试在计算机上打开PHP文件,只需双击它,就会得到同样的东西。

单击运行按钮运行 Apache 或打开终端并从那里启动 Apache。一旦Apache提供它,你可以预览你的PHP文件。