我有一个搜索计算机的 windows 目录的 php 文件。如果我有一个包含非英语字符(如“Önder Şoğlopıpk”)的目录,它会返回 null。我的 PHP 文件是这样的:
$port = $_GET["port"];//Here is computer's port
$path = trim($_GET["path"]);//Here is the path which does not work
$path = str_replace(" ","+",$path);
$path = urlencode($path);
$suffix = $_GET["suffix"];//Here is suffix which I am searching
if($_GET){
$url='http://mylink.com?host=localhost&port='.$port.'&showerrorinxml=yes&link=proc_list?find_files___path='.$path.'___suffix='.$suffix.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);
如果路径变量中有一个非英文字符,例如“Ş Ğ ı ş ğ I”,它会返回 null 给我。如果是英文就没有问题。我可以搜索我想要的。我正在对其进行urlencoding,但它没有用。对于名为“Seçpa Yazılım Login”的目录,我的 url 似乎是:
http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSe%C3%A7pa%2BYaz%C4%B1l%C4%B1m%2BLogin%2F___suffix=.css
它似乎在浏览器上,这样:
http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSeçpa%2BYazılım%2BLogin%2F___suffix=.css
有人对这个话题有想法吗?