Home > Backend Development > PHP Tutorial > Why are the square brackets of optional parameters of functions in the thinkphp manual an inclusive relationship?

Why are the square brackets of optional parameters of functions in the thinkphp manual an inclusive relationship?

WBOY
Release: 2016-09-21 14:12:57
Original
1174 people have browsed it

For example:

<code>int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )</code>
Copy after login
Copy after login

Why are the optional parameters in square brackets written like this:
For example, the first optional parameter array &$matches has a [,
Why is the previous parameter added in the background?

In addition, the way it is written in the manual gives the impression that:
$matches includes $flags, and $flags includes $offset
Why is it written like this?

Is there really an inclusive relationship between these parameters?

Reply content:

For example:

<code>int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )</code>
Copy after login
Copy after login

Why are the optional parameters in square brackets written like this:
For example, the first optional parameter array &$matches has a [,
Why is the previous parameter added in the background?

In addition, the way it is written in the manual gives the impression that:
$matches includes $flags, and $flags includes $offset
Why is it written like this?

Is there really an inclusive relationship between these parameters?

is better understood as an optional dependency. For example, flags is an optional dependency of matches. That is to say, when you provide the matches parameter, you can choose to provide flags to match matches Working together, that is, without matches, individual flags will have no effect.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template