Php function learning 11. stringdirname (stringpath) -- return part of the directory in the path. Example 1: & lt ;? Php ??? $ PathetcmyMusic ;??? $ Filedirname ($ path); the variable file is etc ??? Echo $ file ;??? & Gt; 2. stringbasename (stri php function Learning 1
1. string dirname (string path) -- Return the contents in the path.
Example 1:
??? $ Path = "/etc/myMusic ";
??? $ File = dirname ($ path); // The variable file is/etc.
??? Echo $ file ;??
?>
2. stringBasename(String path [, string suffix]) -- returns the file name part of the path.
Example 1:
??? $ Path = "/etc/myMusic/index. php ";
??? $ Filename = basename ($ path, '. php'); // The variable filename is index
??? $ Filename1 = basename ($ path); // The variable filename1 is index. php
??? Echo $ filename;
?>
3. arrayPathinfo(String path) -- returns the file path information,
Pathinfo ()Returns a combined array containingPath. Includes the following array units:Dirname,BasenameAndExtension.
??? $ Path_parts = pathinfo ("/www/htdocs/index.html ");
??? Echo $ path_parts ["dirname"]."
";
??? Echo $ path_parts ["basename"]."
";
??? Echo $ path_parts ["extension"]."
";
?>
Running result:
/Www/htdocs
Index.html
Html
4. stringRealpath(String path) -- returns the normalized absolute path.
Realpath ()Extends all symbolic connections and processes the inputPath'/./', '/./', And the excess '/' and return the normalized absolute path name. There is no symbolic connection in the returned path, '/./' or.
Example 1:
??? $ Path = realpath ("C :\\\.. \. \. \\\ wamp \. \\\ www \\. \. \. \ php \ realpath. php ");
??? Echo $ path;
?>
Running result:
C: \ wamp \ www \ php \ realpath. php
?
?
?
?
?
?
?
?