doujin8673 2016-02-01 19: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 06: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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了