-1
我得到我的網頁上下面的輸出,當我去的test.php:PHP錯誤,找不到類
longitude = $long;
$this->latitude = $lat;
}
public function getgeo(){
require_once('lib/mapbox/MapBox.php');
$request = new MapBox('redacted');
$request = $request->reverseGeocode($this->longitude,$this->latitude);
$request = explode(', ',$request[0]['place_name']);
if(count($request)>3){
array_shift($request);
array_splice($request,2,1);
}
$return = array($request[0],$request[2]);
}
}
?>
Fatal error: Uncaught Error: Class 'ReverseGeo' not found in /var/www/html/api.redacted.com/public_html/test.php:8 Stack trace: #0 {main} thrown in /var/www/html/api.redacted.com/public_html/test.php on line 8
test.php的
<?php
require_once(__dir__ . '/classes/reversegeo.php');
$long = '-73.988909';
$lat = '40.733122';
$reversegeo = new ReverseGeo($long, $lat);
$return = $reversegeo->getgeo();
var_dump($return);
?>
classes/reversegeo.php
Class ReverseGeo{
protected $longitude;
protected $latitude;
public function __construct($long, $lat){
$this->longitude = $long;
$this->latitude = $lat;
}
public function getgeo(){
require_once('lib/mapbox/MapBox.php');
$request = new MapBox('redacted');
$request = $request->reverseGeocode($this->longitude,$this->latitude);
$request = explode(', ',$request[0]['place_name']);
if(count($request)>3){
array_shift($request);
array_splice($request,2,1);
}
$return = array($request[0],$request[2]);
}
}
我已經確認目錄都是正確的,文件名是正確的,等等,我不知道這是怎麼回事。
如果您檢查頁面,是否顯示源代碼中的完整代碼? [看到這個問題](http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – Qirel
它確實顯示完整的代碼來源。 – Kaylined
做一個'var_dump(__ dir __)'看看你得到了什麼 – CodeGodie