我在Windows 7计算机上安装了wamp服务器.它显示所有服务正在运行.它运行着Apache,PHP和MySQL.我安装了最新的Chrome浏览器.
我正在尝试在网站上运行以下代码,但是我只获得了基本的HTML页面,而没有PHP脚本.
这是我的代码:
Php TutorialPhp tutorials
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "testing";
print_r($_REQUEST);
?>
我环顾四周,他们建议我安装PHP,Apache和MySQL.我有三个使用wamp服务器与phpMyAdmin一起运行.我想念什么?
我修复了将测试视为不是字符串的问题,并添加了错误报告,但是我仍然看不到网页上显示测试.
解决方法:
As per your original post-@JayBlanchard所说的有关使用错误报告的用法,将触发未定义的常量测试通知.
因此,您需要将“测试”一词用引号引起来:
echo "testing";
将error reporting添加到文件顶部,这将有助于发现错误.
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
旁注:错误报告仅应在登台进行,而不应在生产过程中进行.
查阅有关字符串的手册:
以及常量:
如果要使用常量,则只需定义它:
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?
OP: it looks like file:///C:/xy
>应该是http://localhost/file.php
标签:apache,mysql,php
来源: https://codeday.me/bug/20191120/2043930.html