Php function Learning 1

Source: Internet
Author: User
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

?

?

?

?

?

?

?

?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.