我有一個簡單的模式對話框,我在我自己的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