简体   繁体   English

使用 WAMP 服务器无法始终如一地执行 PHP 代码

[英]PHP Code not consistently executing using WAMP Server

I have a WAMP Server up and running to test PHP code for a class I am taking.我有一个 WAMP 服务器启动并运行以测试我正在学习的课程的 PHP 代码。 The WAMP Server icon is green, and I have HTML and PHP files in my www folder that run without issue. WAMP 服务器图标是绿色的,我的 www 文件夹中有 HTML 和 PHP 文件,可以正常运行。 I also have my WAMP running PHP v7.0.1我的 WAMP 也运行 PHP v7.0.1

I'm having an issue with one particular file, some of the PHP code will execute but not all of it.我遇到了一个特定文件的问题,一些 PHP 代码将执行,但不是全部。 I'm not able to determine why.我无法确定原因。 I've put this PHP code into online PHP processors and it spits out exactly what it is supposed to (timestamped date).我已将此 PHP 代码放入在线 PHP 处理器中,它会准确地输出预期的内容(带时间戳的日期)。 Here is how the PHP is displayed when I run the file in a web browser:以下是我在 Web 浏览器中运行文件时 PHP 的显示方式:

Image of Web Page网页图片

Here is the contents of my PHP file:这是我的 PHP 文件的内容:

<html>
<head>
 <title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
    echo '<p>Order processed at ';
    echo date('H:1, jS F');
    echo '</p>'
?>
</body>
</html>

` `

As you can see, the data echo does not work for some reason.如您所见,由于某种原因,数据回显不起作用。 However the echo for order processed works no problem.然而,订单处理的回声工作没有问题。

Any assistance would be much appreciated.任何帮助将不胜感激。 I am new to PHP and web servers and my class only meets once a week.我是 PHP 和 Web 服务器的新手,我的班级每周只开一次会。 It's been difficult to get help from my Professor and I've been stuck trying to figure this out for a while.很难从我的教授那里获得帮助,我一直在努力解决这个问题。

From your screenshots, you're opening the php script like a plain html file :从您的屏幕截图中,您正在像普通的 html 文件一样打开 php 脚本:

file:///C:/wamp64/www/procecssorder2.php

You should request the web page from your apache server, most probably via :您应该从您的 apache 服务器请求网页,最有可能是通过:

http://localhost/procecssorder2.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM