Hướng dẫn pathinfo php - pathinfo php

Hàm pathinfo[] sẽ lấy thông tin về đường dẫn truyền vào.

Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức.freetuts.net, không được copy dưới mọi hình thức.

Cú pháp

Cú pháp: pathinfo[ $path, $option];: pathinfo[ $path, $option];

Trong đó::

  • $path là đường dẫn cần lấy thông tin.
  • $option là tham số không bắt buộc, có thể mang một trong các giá trị sau: PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION , PATHINFO_FILENAME.

Kết quả trả về

  • Nếu $option không được truyền vào, hàm sẽ trả về một mảng bao gồm các phần tử: dirname, basename, extension[ nếu đường dẫn truyền vào không có phần mở rộng thì mảng trả về sẽ không có phần tử extension], and filename.
  • Nếu $option được truyền vào hàm sẽ trả về chuỗi là giá trị mà $option yêu cầu.

Ví dụ

Ví dụ về cách sử dụng hàm pathinfo[]:

Bài viết này được đăng tại [free tuts .net]

Code

$path = 'C:\xampp\php\php.ini'; $arr = pathinfo[$path]; echo ""; print_r[$arr]; echo "";

Kết quả

Array [ [dirname] => C:\xampp\php [basename] => php.ini [extension] => ini [filename] => php ]

Sử dụng tham số $option:

Code

$path = 'C:\xampp\php\php.ini'; $arr = pathinfo[$path]; echo ""; print_r[$arr]; echo "";

Kết quả

[Php 4> = 4.0.3, Php 5, Php 7, Php 8]

Nội dung chính ShowShow

  • Sự mô tả
  • pathInfo [] là nhận thức được ngôn ngữ, vì vậy để nó phân tích một đường dẫn chứa các ký tự multibyte một cách chính xác, locale phù hợp phải được đặt bằng hàm setLocale [].
  • Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.
  • Thận trọng
  • ________số 8

PathInfo - Trả về thông tin về đường dẫn tệp — Returns information about a file pathReturns information about a file path

Sự mô tả

pathInfo [] là nhận thức được ngôn ngữ, vì vậy để nó phân tích một đường dẫn chứa các ký tự multibyte một cách chính xác, locale phù hợp phải được đặt bằng hàm setLocale [].[string

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
7, int
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
8 =
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
9
]: array|string

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.:

Thận trọng

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.:

Thận trọng operates naively on the input string, and is not aware of the actual filesystem, or path components such as "

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
3".

________số 8

PathInfo - Trả về thông tin về đường dẫn tệp — Returns information about a file path is locale aware, so for it to parse a path containing multibyte characters correctly, the matching locale must be set using the setlocale[] function.

pathInfo [] là nhận thức được ngôn ngữ, vì vậy để nó phân tích một đường dẫn chứa các ký tự multibyte một cách chính xác, locale phù hợp phải được đặt bằng hàm setLocale [].

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.

Thận trọng

________số 8

PathInfo - Trả về thông tin về đường dẫn tệp — Returns information about a file path

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
6,

pathinfo [chuỗi
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
7, int
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
8 =
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
9]: mảng | chuỗi[string
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
7, int
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
8 =
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
9]: array|string0,
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1
or
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2
.

Ghi chú::

Để biết thông tin về việc truy xuất thông tin đường dẫn hiện tại, hãy đọc phần về các biến được đặt trước được xác định trước.

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.

Thận trọngarray containing the following elements is returned:

________số 8

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.:

Thận trọng

________số 81 returns only the last one and
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2
only strips the last one. [see first example below].

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.:

Thận trọng

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.:

Thận trọng

________số 8string containing the requested element.

Thận trọng

________số 8pathinfo[] Example

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
29

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
70

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
71

Nếu flags không được chỉ định, hãy trả về tất cả các yếu tố có sẵn.

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
3

Thận trọngpathinfo[] example showing difference between null and no extension

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
72

________số 8

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL

PathInfo - Trả về thông tin về đường dẫn tệp — Returns information about a file pathpathinfo[] example for a dot-file

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
73

________số 8

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2

________số 8

  • PathInfo - Trả về thông tin về đường dẫn tệp — Returns information about a file path
  • pathinfo [chuỗi
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    7, int
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    8 =
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    9]: mảng | chuỗi[string
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    7, int
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    8 =
    string[0] ""
    
    Notice: Undefined index: extension in test.php on line 6
    NULL
    
    9]: array|string
  • Ghi chú::
  • Để biết thông tin về việc truy xuất thông tin đường dẫn hiện tại, hãy đọc phần về các biến được đặt trước được xác định trước.

Để biết thông tin về việc truy xuất thông tin đường dẫn hiện tại, hãy đọc phần về các biến được đặt trước được xác định trước. operates naively on the input string, and is not aware of the actual filesystem, or path components such as "

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
3".

pathInfo [] hoạt động ngây thơ trên chuỗi đầu vào và không nhận thức được hệ thống tập tin thực tế hoặc các thành phần đường dẫn như "
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
3".1 chỉ trả về cái cuối cùng và
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2 chỉ dải cái cuối cùng. [Xem ví dụ đầu tiên dưới đây].

Thận trọng is locale aware, so for it to parse a path containing multibyte characters correctly, the matching locale must be set using the setlocale[] function.

Thông số7 [xem ví dụ thứ hai bên dưới].

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
74

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
5

Con đường được phân tích cú pháp.6 của
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
5 bắt đầu bằng một dấu chấm, các ký tự sau được hiểu là
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
7 và
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
8 trống [xem ví dụ thứ ba bên dưới].

________số 8

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
6,

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
75

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
76

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
77

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
78

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
0,
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1 or
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2.

Nếu có, chỉ định một yếu tố cụ thể sẽ được trả về; một trong số

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
6,

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
80

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
81

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
82

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
83

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
84

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
85

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
0,
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1 hoặc
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2.

Trả về giá trịarray containing the following elements is returned:

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
86

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
87

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
5,
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
6,
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
7 [if any], and
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
8.

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1 returns only the last one and
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2 only strips the last one. [see first example below].

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
89

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
90

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

Xem thêm ¶

Dirname [] - Trả về đường dẫn của thư mục cha mẹ

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
92

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
93

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

basename [] - Trả về thành phần tên dấu vết của đường dẫn ¶

parse_url [] - phân tích URL và trả về các thành phần của nó

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
95

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
96

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
97

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
98

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

RealPath [] - Trả về tên đường dẫn tuyệt đối chính thức ¶

Lori ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
30

4 năm trước ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
31

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
32

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
33

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
34

6 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
35

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
36

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
37

1 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
38

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
36

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
37

1 năm trước ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
51

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
52

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

Xem thêm ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
54

Xem thêm ¶

Dirname [] - Trả về đường dẫn của thư mục cha mẹ

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
55

basename [] - Trả về thành phần tên dấu vết của đường dẫn ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
56

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
57

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
58

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
59

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

Xem thêm ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
51

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
52

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
53

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
54

Xem thêm ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
55

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
56

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

6 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
58

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
59

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

1 năm trước ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
61

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
62

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

6 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
64

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
65

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
66

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
67

1 năm trước ¶

Lori ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
68

4 năm trước ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
69

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
00
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
01
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
02

6 năm trước ¶

parse_url [] - phân tích URL và trả về các thành phần của nó

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
03

RealPath [] - Trả về tên đường dẫn tuyệt đối chính thức ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
04

6 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
05
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
06
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
07
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
08
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

1 năm trước ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

Pietro Baricco ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
10
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1110 năm trước

parse_url [] - phân tích URL và trả về các thành phần của nó

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
13

RealPath [] - Trả về tên đường dẫn tuyệt đối chính thức ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

Pietro Baricco ¶

Xem thêm ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
10
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1110 năm trước

Tom tại Foo-Bar Dot Co Dot Uk ¶ ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
10
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1110 năm trước

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
27
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
28
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
29
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
30

6 năm trước ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
31

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
36

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
33

Pietro Baricco ¶

498936940 tại qq dot com ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
34
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
35
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
36
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

6 năm trước ¶

Thông tin tại KGSW DOT de ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
38

1 năm trước ¶

parse_url [] - phân tích URL và trả về các thành phần của nó

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
39
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
40
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

RealPath [] - Trả về tên đường dẫn tuyệt đối chính thức ¶

Ví dụ #3 PathInfo [] Ví dụ cho tệp chấm

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
42
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
43
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

Pietro Baricco ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
10
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
1110 năm trước

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
45
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
46

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
36

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
48

Tom tại Foo-Bar Dot Co Dot Uk ¶ ¶

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
14
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
15
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
01
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
17

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
49
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
50
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
51
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
79

Ví dụ #1 PathInfo [] Ví dụ

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
18
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
19
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
20
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
21
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
22
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
23
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
24
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
2510 năm trước

string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
53
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
54
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
55
string[0] ""

Notice: Undefined index: extension in test.php on line 6
NULL
56

Bài Viết Liên Quan

Chủ Đề