PHP echo 不显示在 HTML 中

发布于 2024-10-26 00:19:02 字数 826 浏览 2 评论 0原文

我是 PHP 新手,正在关注 w3schools 上的 PHP tut。我正在使用 Eclipse 的最新 IDE 版本(我认为是 3.6)。对于我的脚本 helloDriver.php,当作为 php 脚本运行时,它运行良好。它不在我的 html 文件中,特别是当我使用与 w3schools 示例类似的方法时: http://www.w3schools.com/PHP/php_forms.asp

这将是我的helloDriver.php 的代码:

<html>
<body>
go
<?php
    echo "giga";
?>
power rangers
</body>
</html>

这是我的 homepage.html 代码

<html>
<body>
Hey
<form action="helloDriver.php">
<input type="submit />
</body>
</html>

“Hey”和“go”都显示,所以我知道 php 文件正在被调用,但我不知道为什么 echo 命令没有被调用。

甚至在此之前,我逐行复制了 w3schools 示例中的内容,但welcome.php 除外,因为它是 helloDriver.php。

我访问 html 文件的方法是双击它,因为 Eclipse 没有任何运行该程序的选项。有什么想法我做错了吗?

I'm new to PHP and I'm following the PHP tut on w3schools. I am using Eclipse's latest IDE version (3.6 I think). for my script helloDriver.php it functions fine when ran as a php script. it doesn't on my html file especially when I use a similar method to the example from w3schools:
http://www.w3schools.com/PHP/php_forms.asp

This would be my code for helloDriver.php:

<html>
<body>
go
<?php
    echo "giga";
?>
power rangers
</body>
</html>

This is my code for homepage.html

<html>
<body>
Hey
<form action="helloDriver.php">
<input type="submit />
</body>
</html>

"Hey" and "go" both display so I know that the php file is being called but I don't know why the echo command doesn't.

Even before this I copied line by line with what the w3schools example was with the exception of welcome.php since that is helloDriver.php

How I access the html file is double clicking it since Eclipse doesn't have any options to run the program. Any ideas what I am doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

揪着可爱 2024-11-02 00:19:02

这些文件托管在哪里?我猜测您的 Web 服务器(例如 Apache 或 IIS)未配置为通过 PHP 解释器运行 .php 文件,而是静态地提供它们。

Where are these files hosted? I'm guessing your web server (e.g., Apache or IIS) isn't configured to run .php files through the PHP interpreter, but instead is serving them statically.

倾城月光淡如水﹏ 2024-11-02 00:19:02

我真的很难弄清楚你的问题是什么。

HTML 文件存在一些问题:

  • 您缺少 结束标记
  • 您尚未关闭提交按钮上的引号。

完整的标记可能应该更像是

<form action="helloDriver.php">
    <input type="submit" />
</form>

另一件事可能是问题,您需要通过 Web 服务器访问 PHP 脚本。你安装过XAMPP之类的东西吗?

I'm having a really hard time working out what your question is.

Some problems with your HTML file are:

  • You're missing the closing </form> tag
  • You haven't closed the quotes on your submit button.

The complete markup should probably be more like

<form action="helloDriver.php">
    <input type="submit" />
</form>

Another thing that might be the problem, you need to access the PHP scripts through a web server. Have you installed something like XAMPP?

尬尬 2024-11-02 00:19:02

我最终弄清楚了。感谢你们的帮助,也感谢您推荐 XAMPP。
从这个链接安装它(谷歌搜索 XAMPP 也可以):
http://www.apachefriends.org/en/xampp-windows.html#1173

设置起来非常简单。设置要安装在 C: 驱动器上的目标。还偶然发现了这个关于如何使用 PHP、XAMPP 和 Eclipse 设置 PHP 项目的视频:
http://www.youtube.com/watch?v=hfHEmZXJLgw

我应该可以通过反复试验来弄清楚事情。再次感谢!

I ended up figuring it out. Thank you guys for help and thanks for suggesting XAMPP.
Installed it from this link (googling XAMPP works just as well):
http://www.apachefriends.org/en/xampp-windows.html#1173

It was straightforward and easy to set up. Set the destination to install on the C: drive. Also stumbled across this tut vid on how to set up a PHP project using PHP, XAMPP, and Eclipse:
http://www.youtube.com/watch?v=hfHEmZXJLgw

I should be able to figure things through trial and error. Thanks again!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文