我班上有以下代码。
$pm->new_route_waypoints = array ();
if($pm->assumed_type == 'O') {
$pm->new_route_start = $pm->addressStart;
$pm->new_route_end = $pm->addressEnd;
$pm->new_route_waypoints [] = $this->_record->addressStart;
$pm->new_route_waypoints [] = $this->_record->addressEnd;
$pm->offer_distance = $pm->totalDistance;
$pm->offer_duration = $pm->totalDuration;
}
else {
$pm->new_route_start = $this->_record->addressStart;
$pm->new_route_end = $this->_record->addressEnd;
$pm->new_route_waypoints [] = $pm->addressStart;
$pm->new_route_waypoints [] = $pm->addressEnd;
$pm->offer_distance = $this->_record->totalDistance;
$pm->offer_duration = $this->_record->totalDuration;
}
当此行$pm->new_route_waypoints [] = $pm->addressStart;
运行时,它会将$ pm-> addressStart作为类读取,自动加载器会尝试加载它。具体来说,它读取变量“123 Main St,Wilson,WY 83014,USA”,然后给出了这个错误:
警告:include_once(/Sites/website/classes/class.123 Main St,Wilson,WY 83014,USA.php)[function.include-once]:无法打开流:/ Sites中没有此类文件或目录第11行/website/testbed_db/startsession.php
有趣的是,它不会在下一行代码$pm->new_route_waypoints [] = $pm->addressEnd;
上抛出相同的错误,该代码具有与导致错误的第一行完全相同的值类型(地址)。
我更改了自动加载器以执行include_once而不是require_once,因此它不会破坏我的代码,但我一直无法弄清楚为什么我会收到此错误。我不认为它与我的自动加载器代码有任何关系,因为我尝试使用__autoload函数替换,但以下是以下代码:
define('ROOT',$_SERVER['DOCUMENT_ROOT'].'/');
function __autoload_libraries($class_name)
{
include_once ROOT."classes/class.".$class_name.".php";
}
spl_autoload_register('__autoload_libraries');
如果您需要更多信息,请告诉我一些想法。
谢谢,
马修