The PATH_SEPARATOR constant and set_include_path are very useful advanced functions of php.

Source: Internet
Author: User
Tags php example
: This article mainly introduces the PATH_SEPARATOR constant and set_include_path, a very useful advanced function of php. For more information about PHP tutorials, see. The index. php example of zendframework contains the following sentence:

Set_include_path ('. '. PATH_SEPARATOR. '.. /library /'. PATH_SEPARATOR. '. /application/models /'. PATH_SEPARATOR. '. /application/lib /'. PATH_SEPARATOR. get_include_path ()); I don't know what PATH_SEPARATOR is. it is actually a constant.

Echo directly knows its value. in linux, it is a ":" number, WIN is a ";" number.

Set_include_path is to set the path of the php inclusion file, which is equivalent to the environment variable of the operating system.

For the set_include_path problem, in win, if you want to include multiple paths, you must use ";" to separate them, but use ":" in linux.

Therefore, the above zf code is out of stock.
Get_include_path: get the existing environment variable

Definition and usage

The pathinfo () function returns the file path information in an array.

Syntax

pathinfo(path,options)
Parameters Description
Path Required. Specifies the path to be checked.
Process_sections

Optional. Specifies the array element to be returned. The default value is all.

Possible values:

  • PATHINFO_DIRNAME-returns only dirname
  • PATHINFO_BASENAME-only return basename
  • PATHINFO_EXTENSION-returns only extension

Description

Pathinfo () returns an associated array containing path information.

Includes the following array elements:

  • [Dirname]
  • [Basename]
  • [Extension]

Tips and comments

Note: if not all units are required, the pathinfo () function returns a string.

Example

Example 1

          

Output:

Array([dirname] => /testweb[basename] => test.txt[extension] => txt)

Example 2

          

Output:

test.txt

Under DIRECTORY_SEPARATOR window

Description

Path separator

Windows

\ Or/

Linux

/

Function _ autoload ($ classname ){

If (preg_match ('/\\\/', $ classname )){

$ Path = str_repace ('\', DIRECTORY_SEPARATOR, $ classname );

} Else {

$ Path = str_replace ('_', DIRECTORY_SEPARATOR, $ classname );

}

Require_once ("$ path. php ");

}

Reprinted from: http://www.cnblogs.com/jackluo/archive/2013/04/09/3010257.html

The above describes the advanced functions PATH_SEPARATOR and set_include_path, which are very useful for php. They include some content and hope to help those who are interested in PHP tutorials.

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.