包含文件时,分页符
When Including a File, Page Breaks
我遇到了一个非常奇怪的问题。在我的本地主机上,一切都按预期工作。当我上传到实时服务器时,页面就在我包含文件的地方中断了。它下面只有白色 space。纳达...
中断的行是:
<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>
包含的文件是:
<?php
/*///////////////////////////////////////////////////////////////////////
Part of the code from the book
Building Findable Websites: Web Standards, SEO, and Beyond
by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com
Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/
function storeAddress(){
// Validation
if(!$_GET['email']){ return "No email address provided"; }
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $_GET['email'])) {
return "Email address is invalid";
}
require_once('MCAPI.class.php');
// grab an API Key from http://admin.mailchimp.com/account/api/
$api = new MCAPI('xxxxxxx');
// grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
// Click the "settings" link for the list - the Unique Id is at the bottom of that page.
$list_id = "xxxxxx";
if($api->listSubscribe($list_id, $_GET['email']) === true) {
// It worked!
// return 'Success! Thank You!';
echo '<script> window.location.href = "thank-you.php"; </script>';
}
else
{
// An error ocurred, return error message
return 'Error: ' . $api->errorMessage;
}
}
// If being called via ajax, autorun the function
if($_GET['ajax']){ echo storeAddress(); }
?>
以上代码中唯一编辑的是 API 键和列表 ID。
这是因为您的 if 条件缺少括号。
require_once('inc/store-address.php');
if($_GET['submit'] **)** {
echo storeAddress();
}
好像出错了。它在我的本地服务器上运行,因为没有错误。
我正在使用 filezilla 上传我的内容。出于某种原因,上传时似乎是编码问题。
我不知道我是否应该删除这个问题或答案以帮助其他人解决问题,所以我选择了后者。
我手动上传了我的文件,猜猜看,成功了!
我遇到了一个非常奇怪的问题。在我的本地主机上,一切都按预期工作。当我上传到实时服务器时,页面就在我包含文件的地方中断了。它下面只有白色 space。纳达...
中断的行是:
<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>
包含的文件是:
<?php
/*///////////////////////////////////////////////////////////////////////
Part of the code from the book
Building Findable Websites: Web Standards, SEO, and Beyond
by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com
Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/
function storeAddress(){
// Validation
if(!$_GET['email']){ return "No email address provided"; }
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $_GET['email'])) {
return "Email address is invalid";
}
require_once('MCAPI.class.php');
// grab an API Key from http://admin.mailchimp.com/account/api/
$api = new MCAPI('xxxxxxx');
// grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
// Click the "settings" link for the list - the Unique Id is at the bottom of that page.
$list_id = "xxxxxx";
if($api->listSubscribe($list_id, $_GET['email']) === true) {
// It worked!
// return 'Success! Thank You!';
echo '<script> window.location.href = "thank-you.php"; </script>';
}
else
{
// An error ocurred, return error message
return 'Error: ' . $api->errorMessage;
}
}
// If being called via ajax, autorun the function
if($_GET['ajax']){ echo storeAddress(); }
?>
以上代码中唯一编辑的是 API 键和列表 ID。
这是因为您的 if 条件缺少括号。
require_once('inc/store-address.php');
if($_GET['submit'] **)** {
echo storeAddress();
}
好像出错了。它在我的本地服务器上运行,因为没有错误。
我正在使用 filezilla 上传我的内容。出于某种原因,上传时似乎是编码问题。
我不知道我是否应该删除这个问题或答案以帮助其他人解决问题,所以我选择了后者。
我手动上传了我的文件,猜猜看,成功了!