return preg_quote("{".$varname."}");
}
/* private: loadfile(string $handle)
* handle: load file defined by handle, if it is not loaded yet.
*/
function loadfile($handle) {
if (isset($this->varkeys[$handle]) and !empty($this->varvals[$handle]))
return true;
if (!isset($this->file[$handle])) {
$this->halt("loadfile: $handle is not a valid handle.");
return false;
}
$filename = $this->file[$handle];
$str = implode("", @file($filename));
if (empty($str)) {
$this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
return false;
}
$str = $this->parsepath($str);//替换图片路径
$this->set_var($handle, $str);
return true;
}
/* 重新分析替换模版目录下指定路径(一般为图片文件路径)
*/
function parsepath($str = ""){
if("/" != substr($this->path, -1)){
$this->path .= "/";
&nb
| 对此文章发表了评论 |
