As efficient as possible, remove the file extension from a standard URL, and then expand the code to get other data, such as: directory path, the principle is to use PHP's explode function to separate strings.
For example: http://www.abc.com/abc/de/fg.php?id=1 need to remove PHP or. php
Very simple, look directly at the code.
Copy Code code as follows:
<?php
$url = "Http://www.abc.com/abc/de/fg.php?id=1";
This is written by yourself.
function GetUrl ($url) {
$date = Explode ('? ', $url);
$date = basename ($date [0]);
$date = Explode ('. ', $date);
return $date [1];
}
Var_dump (GETURL ($url));
The following two are made online
function Getext ($url) {
$arr = Parse_url ($url);
$file = basename ($arr [' path ']);
$ext = Explode (".", $file);
return $ext [1];
}
Var_dump (Getext ($url));
function GetName ($url) {
$w _param = PathInfo ($url);
$str = $w _param[' extension '];
List ($type, $vars) = Explode ('? ', $str);
return $type;
}
Echo ' Start3 '. Date ("y-m-d h:i:s");
?>