“您好,世界";在PHP中什么也不显示 [英] "Hello, World" in PHP displays nothing
问题描述
我是PHP新手,刚下载了PHP,并写了你好,世界!" 程序:
I am new to PHP, just downloaded it, and wrote a "Hello, World!" program:
<html>
<body>
<?php
$fileName = "test.jpg";
$txt = "Hello, World!";
echo $txt;
?>
</body>
</html>
但是它不起作用.我将文件命名为test.php
,并使用Firefox打开了文件,但未显示任何内容.
But it doesn't work. I named the file test.php
and opened it with Firefox and nothing was displayed.
推荐答案
您必须将其通过某种类型的网络服务器传递,例如 Apache ,工作.
You'll have to pass it through a webserver of some kind, for example IIS or Apache, for it to work.
PHP是一种服务器端语言,因此您不能只在浏览器中打开PHP文件.相反,请尝试搜索一些免费的PHP主机,然后将文件上传到那里.
PHP is a server-side language, thus you can't just open the PHP file in a browser. Instead, try googling some free PHP hosts, and upload your files there.
例如,您可以寻求以下解决方案,这些解决方案将为您提供所需的东西:
You could for example go for these solutions that will provide you with what you need:
- WAMP- http://www.wampserver.com/en/(Windows)
- XAMPP- http://www.apachefriends.org/en/xampp.html-(适用于Windows,Mac和Linux)
- WAMP - http://www.wampserver.com/en/ (Windows)
- XAMPP - http://www.apachefriends.org/en/xampp.html - (Windows, Mac, and Linux)
这些解决方案将安装Apache, MySQL 和PHP,并允许您在本地使用PHP进行游戏发展.稍后,如果您要部署代码,则必须找到一个外部主机(或将其托管在您自己的计算机上).
Those solutions will install Apache, MySQL and PHP and allow you to play locally with PHP development. Later on, if you want to deploy your code, you will have to find an external host (or host it on your own computer).
这篇关于“您好,世界";在PHP中什么也不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!