私はまだPHPを学んでいます。どのようにルートディレクトリを抽出しますか?
'SCRIPT_FILENAME' => string 'D:/Project Storage/wnmp/www/folder/index.php' (length=45)
'SCRIPT_NAME' => string '/folder/index.php' (length=18)
'DOCUMENT_URI' => string '/folder/index.php' (length=18)
'PHP_SELF' => string '/folder/index.php' (length=18)
'REQUEST_URI' => string '/folder/helloworld/helloworldtwo/etc' (length=15)
あなたは私だけにhelloworld/helloworldtwo/etc
任意のアイデアは、フォルダを抽出取得したい見ることができるように?だからhelloworld/helloworldtwo/etc
になるでしょうか?
どのような考えが私のフォルダを$root = 'folder'
のように定義していますか?一致すれば抽出しますが、問題は何ですか?
第2のアイデアは、/first/second.php、 から最初のものを得るためにphp_selfまたは上記のものから取得することですが、もう一度、それを行う最良の方法はわかりません。
と正面に2つのフォルダがある場合は別の問題がありますか? btwはリプレイのすべてのおかげで、私はまだいくつかのphp.netを読んで、テストしてみてください。
'SCRIPT_FILENAME' => string 'D:/Project Storage/wnmp/www/folder/index.php' (length=45)
'SCRIPT_NAME' => string '/folder/folder2/index.php' (length=18)
'DOCUMENT_URI' => string '/folder/folder2/index.php' (length=18)
'PHP_SELF' => string '/folder/folder2/index.php' (length=18)
'REQUEST_URI' => string '/folder/folder2/helloworld/helloworldtwo/etc' (length=15)
質問は同じですが、私はhelloworld/hellowrodltwo/etcを正しい方法で入手できますか?
編集* みんなのおかげでたくさんの私は解決策
$str = 'folder/folder/helloworld/helloworldtwo/etc';
$folder = 'folder/folder';
$q = str_replace($folder, NULL, $str);
echo $q;
を行っているが、何も/代替またはそれを行うには良い方法がある場合に行ってください。
もう一度おねがいします。
[parse_url](http://php.net/manual/en/function.parse-url.php)と[pathinfo](http:// uk3。 php.net/manual/en/function.pathinfo.php) - 関連する関数(basenameなど)? – Mike