我有一个php脚本,如下所示:
<?php
$confirmationCode = trim($_GET['confcode']);
$_SERVER['REMOTE_ADDR'] = 'xxx.xxx.xxx.xxx';
$emailLogId = 1;
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>' .'xxxxx' . $emailLogId . '###'; //exit ;
}
if( is_numeric($emailLogId)) {
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>yyy' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
//$osDB->query('UPDATE ! SET clicktime=? WHERE id=?', array('email_logs', time(), $emailLogId));
} else {
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>zzz' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
}
?>
它正在我的服务器上运行。事实上,有些人抱怨他们在浏览器上看到了这个脚本的源代码(粘贴在下面),他们给我发了这个问题的快照:
' .'xxxxx' . $emailLogId . '###'; //exit ;
}
if( is_numeric($emailLogId)) {
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>yyy' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
//$osDB->query('UPDATE ! SET clicktime=? WHERE id=?', array('email_logs', time(), $emailLogId));
} else {
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>zzz' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
}
?>
事实上,我真的很困惑,因为我无法重现这个问题,但3-4个人都在抱怨同样的事情。
你知道问题出在哪里吗?
2件事:
Apache配置
确保php引擎处于打开状态。如果您无法访问apache配置文件,请将其添加到.htaccess:中
php_flag engine on
CDN
如果您正在使用任何云分发网络,那么是时候让他们清除您现有的缓存并重新加载新的缓存了。
浏览器将显示PHP源代码ONLY AND ONLY若apache配置出错。
希望能有所帮助。
编辑:
在阅读了Sabin的评论后,我再次查看了代码。
问题是,他已将值分配给$_SERVER['REMOTE_ADDR']
(第3行)
它应该是这样的:
<?php
$confirmationCode = trim($_GET['confcode']);
$ip = 'xxx.xxx.xxx.xxx';
$emailLogId = 1;
//Whatever conditions.
if ($_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') {
// print '<pre>' .'xxxxx' . $emailLogId . '###'; exit ;
}
if( is_numeric($emailLogId)) {
if ($_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') {
// print '<pre>yyy' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
//$osDB->query('UPDATE ! SET clicktime=? WHERE id=?', array('email_logs', time(), $emailLogId));
} else {
if ($_SERVER['REMOTE_ADDR']=='xxx.xxx.xxx.xxx') {
// print '<pre>zzz' . $_GET['emaillog_id'] . 'yyyxxxxxx ' . $emailLogId; print_r ($row) ; exit ;
}
}
?>
但是,回显源代码不可能是由于这个原因。我想请你把完整的文件,这样我们就可以看看你是否错过了一个结束单引号!
听起来PHP根本不工作。您没有看到第一部分的唯一原因是,您的浏览器正在将其解析为HTML标记。
请尝试打印phpinfo()一次,
请查看下面的链接,了解更多详细信息
浏览器中显示的PHP代码