我有下面的代碼片段:
function RemoveSubdir(){
// Get the requested path (including all slashes) and Convert to lowercase
$Request_Path = strtolower($_SERVER['REQUEST_URI']);
// Create an array, exploding at the forward slash
$Request_Path = explode('/',$Request_Path);
// return the last element being the file name requested
$Arr_Elements = end($Request_Path);
if (empty($Arr_Elements)){
return prev($Request_Path);
}
return $Arr_Elements;
}
$Directory_Manipulation = RemoveSubdir();
echo $Directory_Manipulation;
var_dump(strpos('global.inc.php',$Directory_Manipulation));
我目前指着我的瀏覽器,以正確的文件路徑(即127.0.0.1/PayC/Global.inc.php)從RemoveSubdir()
收益返回預計..一切都在這個時刻運行良好global.inc.php的正確值,現在不正確的/出乎意料的驗證來自的代碼塊:
strpos('global.inc.php',$Directory_Manipulation);
現在,我是e xpecting這個返回以外的任何其他false
,這是很好的,當URI是:
127.0.0.1/PayC/Global.inc.php
如圖所示:int(0)
但隨着的
127.0.0.1/PayC/Global.inc.php的URI?
我得到的回報:bool(false)
我知道我可以在PHP擴展後刪除尾隨參數,但我要離開這些完整。我已經試過進一步調試,但一直請求var_dumping
並在此發佈我的結果
啊。我們走了。即使在查看文檔之後..我正在以錯誤的方式獲取參數。謝謝 –