PHP Common functions

Source: Internet
Author: User

pathinfo () functionDefinition and usage

The PathInfo () function returns information about the file path in the form of an array.

The returned array elements are as follows:

    • [DirName]
    • [BaseName]
    • [Extension]

Http://www.runoob.com/php/func-filesystem-pathinfo.html

basename () function

Http://www.runoob.com/php/func-filesystem-basename.html

The basename () function returns the file name portion of the path.

Instance
1<?PHP2 $path= "/testweb/home.php";3 4 //Show filename with file extension5 Echo basename($path) ." <br/> ";6 7 //Show filename without file extension8 Echo basename($path, ". PHP");9?>

The above code will output:

home.php
Home

filesize () functionDefinition and usage

The FileSize () function returns the size of the specified file.

If successful, the function returns the number of bytes in the file size. If it fails, it returns FALSE.

Grammar

filesize(filename)

Http://www.runoob.com/php/func-filesystem-filesize.html

Php_eol

Line break

UNIX series with \ n

Windows series with \ r \ n

Mac with \ r

PHP can be replaced with Php_eol to improve code-level portability

1 <? PHP 2     Echo Php_eol ; 3     // the Windows platform is equivalent to    echo "\ r \ n"; 4     //unix\linux platform equivalent to    echo "\ n"; 5     //mac platform equivalent to    echo "\ r";

get_defined_constants()返回所有常量数组

Similar to what is commonly used

Directory_separator

You can use the function get_defined_constants () to get all the PHP constants

1 <? PHP 2     Print_r (get_defined_constants()); // get_defined_constants () returns all constant arrays

PHP Common functions

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.