doujin8673 2016-02-02 03:45
浏览 35
已采纳

使用cloud9学习php

My class is learning coding. It does not go over php, so I am trying to learn it myself. We use jsbin and cloud9. Cloud9 is very nice but I am having trouble using it. I want to follow along with a specific tutorial.

this is the tutorial for php. http://www.chickensmoothie.com/tutorial/tut2/index.html

I have made a html file and a php file, with the same code. This is the code:

<!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> 

end script

If I save it as an html file it displays "first page" just fine, but not the php image when I preview the webpage. the tutorial clearly states that when it works you should be able to see the image, and that if you do not see an image it has gone wrong. So then I saved it as a php file. I click the same run and preview button that correctly displays a webpage for an html file's preview. yet, instead of displaying a website it opens a blank page AND downloads a text file to my desktop. the text file is the actual php text.

does anyone know how to preview php in cloud9, or any website that is specifically for writing/testing php?

  • 写回答

1条回答 默认 最新

  • dongtun1872 2016-02-02 14:40
    关注

    PHP files need to be served up with Apache2. If you try to open a PHP file on your computer, you'll get this same thing if you simply double click it.

    Click the run button to run Apache or open a terminal and start Apache from there. Once Apache is serving it up, you can preview your PHP file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配