PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用Wamp Server时PHP脚本不起作用大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我在Windows 7计算机上安装了wamp服务器.它显示所有服务正在运行.它运行着Apache,PHPMysqL.我安装了最新的Chrome浏览器.

我正在尝试在网站上运行以下代码,但是我只获得了基本的HTML页面,而没有PHP脚本.

这是我的代码

<html>

<head>
    <title>PHP Tutorial</title>
</head>

<body>

    <h3>PHP tutorials</h3>
    <hr>

    <a href="?page=home">Home</a>
    <a href="?page=tutorial">Tutorials</a>
    <a href="?page=about">About</a>
    <a href="?page=contact">Contact</a>
    <hr>

    <?PHP
    error_reporTing(E_ALL);
    ini_set('display_errors', 1);
    echo "tesTing";
    print_r($_requEST);

    ?>

</body>

我环顾四周,他们建议我安装PHP,Apache和MysqL.我有三个使用wamp服务器与@L_511_6@myAdmin一起运行.我想念什么?

我修复了将测试视为不是字符串的问题,并添加错误报告,但是我仍然看不到网页上显示测试.

解决方法:

As per your original post-@JayBlanchard所说的有关使用错误报告的用法,将触发未定义的常量测试通知.

因此,您需要将“测试”一词用引号引起来:

echo "tesTing";

error reporting添加文件顶部,这将有助于发现错误.

<?PHP 
error_reporTing(E_ALL);
ini_set('display_errors', 1);

// rest of your code

旁注:错误报告仅应在登台进行,而不应在生产过程中进行.

查阅有关字符串的手册:

> https://php.net/language.types.string

以及常量:

> http://php.net/manual/en/language.constants.php

如果要使用常量,则只需定义它:

define('tesTing', 'this part gets printed, not the name of the constant');

公认的约定是使用大写单词作为常量的名称,因此与其进行“测试”而不是“测试”.

define('TESTinG', 'this part gets printed, not the name of the constant');

然后可以使用常量:

echo TESTinG; // no quotes, echos 'this part gets printed, not the name of the constant'

编辑:

根据您的编辑:您的文件扩展名实际上是.PHP,您如何访问它?作为http://localhost/file.PHP还是file:///file.PHP

>应该是http://localhost/file.PHP

大佬总结

以上是大佬教程为你收集整理的使用Wamp Server时PHP脚本不起作用全部内容,希望文章能够帮你解决使用Wamp Server时PHP脚本不起作用所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: