一个小小的疑问 在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); } } 只允许字符串以数字9组成,怎么表示? PHP如何把数据写入JSON文件并在另一PHP文件读取JSON数据? 如何在网页输入框输入一段PHP代码,然后提交让服务器运行此代码,并返回结果? php 利用404 这种方法生成伪静态,可取吗? 求一个PHP的考试代码程序参考,谢啦~ 随着中国元素网业务蒸蒸日上的发展,现在需要招聘兼职网站PHP程序员: 求一个php 日历排班的例子 请问PHP用正则表达式字符串,只想保留第一个该如何做? 关于php画图的问题(60分) PHP 多维数组指定键值,获取下标 求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);
}
}