问题描述
我已经知道如何使用 include
, require
甚至 require_once
。我一直练习的是:
I already know how to use include
, require
and even require_once
. What I have always practiced is this:
例如包括'sample.php';
或 require_once'classes / DB.php';
但在某些方面我常常在一些论坛和教程中看到,甚至在这里他们正在使用它 - include('sample.php');
和 require_once('classes / DB.php');
。
But in some ways I often see in some forums and tutorials and even here that they are using it like this - include ('sample.php');
and require_once ('classes/DB.php');
.
我知道任何一个都可行,但我只是想知道你推荐什么可能是一个好习惯? XD,如果已经在这里询问过,请告诉我链接,因为我找不到它。
I know that any of this will work, but I just want to know what would you recommend maybe as a good practice? XD and if it's already been asked here please show me the link because I can't find it.
推荐答案
包括'sample.php';
或 require_once'classes / DB.php';
是首选方式。
。
附注:
1。 require / include
不是一个函数,它们的语言构造与 echo
相同。 致谢: @Rahil评论。
1. require/include
not a function they are language construct same as echo
. Credits: @Rahil comment.
2。此外,它还可以节省按两次击键的时间(
& )
对于像我们这样的懒惰的开发者:p
2. Also it will save time of pressing two keystroke (
& )
for a lazy developers like us :p
这篇关于在php中使用包括或不包括括号的正确方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!