Foreword:
Sometimes we need to create some separate PHP files, but the PHP files placed casually cannot compile the tags of Dedecms, so We need to introduce the compilation engine solution of Dreamweaver tag.
For example, we create example.php in the root directory, the code is as follows:
<span style="font-size:14px;"><span style="font-family:tahoma,geneva,sans-serif;"><?php require_once (dirname(__FILE__)."/include/common.inc.php"); require_once DEDEINC.'/arc.partview.class.php'; $tempfile = $cfg_basedir.$cfg_templets_skin.'/example.htm';//定义模板路径 $pv = new PartView();//初始化类 $pv->SetTemplet($tempfile);//设定模板文件路径 $pv->Display();//显示该页面 ?></span></span>
Then create a template file of example.htm in the current template directory, in this template file Use the global tag of the Dreamweaver system.
Let’s do an analysis:
require_once (dirname(__FILE__)."/include/common.inc.php");
In this place, the Dreamweaver database configuration file (or called: core function configuration file) common under the include folder is actually introduced. inc.php, here we use the require_once() statement mainly when multiple files need to be included, which can effectively avoid the error of repeated definition of functions or variables due to the inclusion of the same piece of code.
The dirname(__FILE__) is to obtain the absolute path of calling the PHP file. As we all know, enabling absolute path compilation will be faster than relative paths. So we can summarize the above code as: introduce a common.inc.php file in the include folder of the root directory.
Next:
require_once DEDEINC.'/arc.partview.class.php';
The code is the same: it can be understood as introducing include
Recommended tutorial: dede tutorial
The above is the detailed content of How to add and introduce php files in dedecms. For more information, please follow other related articles on the PHP Chinese website!