URL of my site is:
http://mc.net46.net/ + folderName + fileName
Run Code Online (Sandbox Code Playgroud)
For example:
http://mc.net46.net/mc/file01.php
http://mc.net46.net/mx/file05.php
Run Code Online (Sandbox Code Playgroud)
folderName is always two characters long.
$address = 'http://mc.net46.net'.$_SERVER["REQUEST_URI"];
Run Code Online (Sandbox Code Playgroud)
result: http://mc.net46.net/mc/file01.php - ok
$fname = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
Run Code Online (Sandbox Code Playgroud)
result: file01.php - ok
Two questions:
Is this the correct way to get $address and $fname ?
How to get folderName?
Try this for another way to get your dynamic file names:
<?php
$fname = "http://mc.net46.net/mc/file01.php";
OR
$fname = $_SERVER["REQUEST_URI"];
$stack = explode('/', $fname);
$ss = end($stack);
echo $ss;
?>
Run Code Online (Sandbox Code Playgroud)
Here for $fname you can use this $fname = explode('/', $_SERVER["REQUEST_URI"]);
| 归档时间: |
|
| 查看次数: |
195 次 |
| 最近记录: |