我有一个简单的模式对话框,我在我自己的linux服务器上开发,运行php 5.3。脚本(如下所示)在我的服务器上运行良好。但是,我将它移到了我的客户端的linux服务器上,而不是回显它显然应该执行的文本/ html,而是从>(大于)字符开始回显所有实际的php代码。有谁知道它为什么会回显实际的代码?有没有一个php.ini设置导致这个?或两种设置中的文件编码差异?php脚本输出php代码,不知道为什么
<?php
$to_email = '[email protected]';
$link = $_GET['link'];
if(!$link){
echo '<p>Have a suggestion?<br />Enter the URL below!</p>';
}else if(strlen($link) > 256 || !preg_match('/^(http:\/\/)?subdomain\.somesite\.com\/(somedir\/)?anotherdir\/(.+)/',$link) && !preg_match('/^(http:\/\/)?somedomain2\.com\/somedir2\/(.+)/',$link)){
echo '<p class="error">Whoops, the URL entered doesn\'t <br />match the criteria.</p>';
}else{
$link = str_replace("\n.", "\n..", $link);
if(!preg_match('/^http:\/\//',$link)){
$link = 'http://'.$link;
}
mail($to_email, 'New URL Suggestion', "A new URL has been suggested from your site:\n\n".$link,"From: ".$to_email."\r\n");
echo '<p>Thank you for submitting this URL! <br />It should be live within 24 hours.</p>';
}
?>
结果我的客户的服务器是:
256 || !preg_match('/^(http:\/\/)?subdomain\.somesite\.com\/(somedir\/)?anotherdir\/(.+)/',$link) &&
!preg_match('/^(http:\/\/)?somedomain2\.com\/somedir2\/(.+)/',$link)){ echo '
Whoops, the URL entered doesn\'t
match the criteria.
'; }else{ $link = str_replace("\n.", "\n..", $link);
if(!preg_match('/^http:\/\//',$link)){ $link = 'http://'.$link; } mail($to_email,
'New URL Suggestion', "A new URL has been suggested from your site:\n\n".$link,"From:
".$to_email."\r\n"); echo '
Thank you for submitting this URL!
It should be live within 24 hours.
'; } ?>
PHP没有得到解析。你在做什么扩展? – 2010-10-18 21:09:18
我想这就是你在屏幕上看到的内容......如果你看看代码,你不知道整个PHP代码吗? – greg0ire 2010-10-18 21:11:21
最可能的是整个PHP代码被发送,但开放<?被浏览器作为HTML标记进行互动,因此if()中的所有内容都隐藏起来了。查看网页来源,它将全部在那里。 – 2010-10-18 21:18:37