PHP:怎样在类里面引入某一个PHP.file呢

来源:百度知道 编辑:UC知道 时间:2024/05/27 19:32:09
main.php
<?php
include "class/Smarty.class.php";
include 'modules/UserIm.php' ;
define('__SITE_ROOT', 'c:/appserv/www/demo'); // 最后没有斜线
$tpl = new Smarty();
$user =new UserIm();
$tpl->template_dir = __SITE_ROOT . "/templates/";
$tpl->compile_dir = __SITE_ROOT . "/templates_c/";
$tpl->config_dir = __SITE_ROOT . "/configs/";
$tpl->cache_dir = __SITE_ROOT . "/cache/";
$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';

?>

我想让class UserAction {

function register(){}
function login(){}
function findalluser(){}
}
我想让useraction类的每个方法都引入main.php这段代码,怎么引入啊,我怎么引都是错误的,求大侠指点

你可以在UserAction的文件头include 'main.php'。
没有人那么白痴在成员上每次调用Smarty,一般都是把初始化设置写在config.php上,之后每个程序都include 'config.php'。

<?php include('include/top.php');

include