我已经知道如何使用 include
、require
甚至 require_once
。我一直实践的是:
例如 include 'sample.php';
或 require_once 'classes/DB.php';
但在某些方面,我经常在一些论坛和教程中看到,甚至在这里,他们是这样使用它的 - include ('sample.php');
和 require_once ('classes/DB.php');
.
我知道这些都行得通,但我只想知道您会推荐什么作为一种好的做法? XD,如果这里已经有人问过,请告诉我链接,因为我找不到它。
最佳答案
include 'sample.php';
或 require_once 'classes/DB.php';
是首选方式。
Is preferred, it will prevent your peers from giving you a hard time and a trivial conversation about what require really is.
旁注:
1. require/include
不是函数,它们是与 echo
相同的语言结构。 致谢: @Rahil 评论。
2. 此外,对于像我们:p
关于php - 在 php 中使用包含或不包含括号的正确方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21572508/