一个小小的疑问 在smarty3中,模板目录$template_dir和编译目录$compile_dir都是用protected修饰的,为什么在类外面可以直接访问呢呢??我把源代码中的protected改成private居然还可以访问,这是为什么呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Smarty类中是这样定义这两个属性的(复制粘贴过来的): protected $template_dir = null; protected $compile_dir = null;这是我写的测试代码: define(ROOT,"C:/www/apache2/htdocs/smarty/"); include ROOT."libs/Smarty.class.php";//包含模板类文件 $smarty = new Smarty();//创建模板对象 echo "编译目录:".$smarty->compile_dir."<br>"; echo "模板目录:".$smarty->template_dir[0]."<br>";这是输出结果:编译目录:.\templates_c\模板目录:.\templates\ 他不是有这样的定义吗? public function __get($name) { $allowed = array( 'template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir', 'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir', 'cache_dir' => 'getCacheDir', ); if (isset($allowed[$name])) { return $this->{$allowed[$name]}(); } else { trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE); } } php(exec,system)外部程序执行问题?!! 维护别人开发的项目,某个页面的php代码返回0,但是浏览器上显示abc,0 php时间低于1970怎么处理 vertrigoserv安装后报如下错误 谁有《零基础学PHP》电子版啊?作者:马忠超 有熟悉jpgraph的朋友没?搞这玩意有没有诀窍啊? 获取数据条数时,当条数为0时,出错,怎么办? 狂急!mysql远程连接突然变慢?不知什么原因? 100万条数据,Apache+PHP+MySQL能否承受? 表格强制换行,奇怪的结果 求PHP开发环境的搭建 关于php curl方面一个很诡异的问题,求思路
Smarty类中是这样定义这两个属性的(复制粘贴过来的):
protected $template_dir = null;
protected $compile_dir = null;
这是我写的测试代码:
define(ROOT,"C:/www/apache2/htdocs/smarty/");
include ROOT."libs/Smarty.class.php";//包含模板类文件
$smarty = new Smarty();//创建模板对象
echo "编译目录:".$smarty->compile_dir."<br>";
echo "模板目录:".$smarty->template_dir[0]."<br>";
这是输出结果:编译目录:.\templates_c\
模板目录:.\templates\
{
$allowed = array(
'template_dir' => 'getTemplateDir',
'config_dir' => 'getConfigDir',
'plugins_dir' => 'getPluginsDir',
'compile_dir' => 'getCompileDir',
'cache_dir' => 'getCacheDir',
); if (isset($allowed[$name])) {
return $this->{$allowed[$name]}();
} else {
trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE);
}
}