简体   繁体   English

PHP包括不执行代码

[英]PHP include not executing code

I have an include in the head of my php file: 我在我的php文件的头部有一个include:

include 'scripts/tracking_code.php';

In there, I run a basic test with if/else and echo some basic text. 在那里,我使用if / else运行基本测试并回显一些基本文本。

Problem is that nothing is getting printed to screen. 问题是没有任何东西被打印到屏幕上。

I then just tried to print something a little more basic... The tracking_code.php now simply includes this: 然后我尝试打印一些更基本的东西...... tracking_code.php现在只包括这个:

echo "<!-- This is the file -->";

Still nothing? 依然没有?

I know the include is getting included because when I turn E_ALL error reporting, the $_GET[] call throws a "Notice: Undefined index:" 我知道include正在被包含,因为当我转向E_ALL错误报告时,$ _GET []调用会抛出“Notice:Undefined index:”

Here is my original code (before simply replacing with "echo" (as above)) 这是我的原始代码(在简单替换为“echo”之前(如上所述))

<?php

$trackingid = $_GET['trackingid'];

if ( !empty( $trackingid ) ) {
    echo "<!-- trackingid: $trackingid -->";
} else { 
    echo "<!-- trackingid is empty -->";
}
?>

Yet nothing is ever printed? 然而什么都没有印刷?

What am I missing? 我错过了什么?

Is your tracking script echo "<!-- This is the file -->"; 您的跟踪脚本是否echo "<!-- This is the file -->"; or is it 或者是它

<?php
  echo "<!-- This is the file -->";
?>

Because without the php tags, there's a good chance that your require call actually makes PHP go "this is not actually a PHP file and as such I cannot require it" but with the error/warning repressed due to whatever error reporting settings are active when you run the code. 因为没有php标签,你的require调用很可能实际上让PHP“这实际上不是一个PHP文件,因此我不能要求它”但由于任何错误报告设置被激活而导致错误/警告被压制你运行代码。

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

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