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
WBOYOriginal
2016-09-21 14:12:571151browse

For example:

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

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>

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.

Statement:
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