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 求指导储层饱和度及含水率测井解释
  • ¥200 建三维地震工区写入sgy到指定目录
  • ¥30 靶向捕获测序探针设计自学
  • ¥15 写代码写代码单片机代码写代码写数字按键代码
  • ¥15 django按照距离进行排序
  • ¥15 (标签-微信|关键词-微信公众号)
  • ¥15 matlab中mjs用不了
  • ¥15 Ios抖音直播的时候如何添加自定义图片在直播间!
  • ¥60 riscv-pulpino总线上挂载axi从机
  • ¥15 ssh登录页面的问题