Home >CMS Tutorial >DEDECMS >How to add and introduce php files in dedecms

How to add and introduce php files in dedecms

王林
王林forward
2020-04-11 17:20:593776browse

How to add and introduce php files in dedecms

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.&#39;/arc.partview.class.php&#39;;    
    $tempfile = $cfg_basedir.$cfg_templets_skin.&#39;/example.htm&#39;;//定义模板路径    
    $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.&#39;/arc.partview.class.php&#39;;

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!

Statement:
This article is reproduced at:dede58.com. If there is any infringement, please contact admin@php.cn delete