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.

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

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效