Is it better to use require_once('filename.php') or require_once 'filename.php';

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-05 15:39:13

问题


Is this just a stylistic difference, or does using require_once('filename.php') vs require_once 'filename.php' have actual load/efficiency differences?


回答1:


It's exactly the same thing. It's a matter of style.

The parentheses may get in the way some times. For instance, this example from the manual doesn't do what you expect:

if (include('vars.php') == 'OK') {
    echo 'OK';
}

See example #4.




回答2:


Pear Coding Standards say :

"include_once and require_once are statements, not functions. Parentheses should not surround the subject filename."

Source : http://pear.php.net/manual/en/standards.including.php




回答3:


What does your heart tell you?

Performance difference, if any: negligible.




回答4:


There is no difference. I don't use the brackets 'cause they are not necessary. require_once is no function.



来源:https://stackoverflow.com/questions/3393847/is-it-better-to-use-require-oncefilename-php-or-require-once-filename-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!