且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么时候应该在 require/include 语句中使用括号?

更新时间:2023-02-16 23:07:19

你被允许在 'include/require' 中使用括号不是因为 include 允许它本身而是因为你可以在 PHP 中的任何字符串或数字周围使用括号进行分组.

You are allowed to use parentheses in 'include/require' not because include allows it itself but because you can use parentheses around any string or number in PHP for grouping.

例如,"dog" 等价于 ("dog")("dog")."dog" 是相当于"dog"."dog"

So for example, "dog" is equivalent to ("dog"), ("dog")."dog" is equivalent to "dog"."dog", etc.

当您使用涉及计算和字符串连接的复杂表达式时,括号会变得很有用,但在这种简单的情况下,它们只是被允许使用并对单个字符串值执行不必要且无害的分组".

Parentheses become useful when you use complex expressions involving calculations and string concatenations but in such a simple case, they are simply allowed and perform an unnecessary and harmless "grouping" of a single string value.