Не кидайтесь плиз камнями, но сам я не знаю как исправить ошибку. Notice: Undefined property: template::$fors in /var/www/u0685127/data/www/ulibkaplus.tk/lib/tmpl.class.php on line 55 Notice: Undefined offset: 1 in /var/www/u0685127/data/www/ulibkaplus.tk/lib/tmpl.class.php on line 55 Notice: Undefined offset: 2 in /var/www/u0685127/data/www/ulibkaplus.tk/lib/tmpl.class.php on line 55 Notice: Undefined offset: 3 in /var/www/u0685127/data/www/ulibkaplus.tk/lib/tmpl.class.php on line 55 Код (Text): <? class template { private $root_path = '_SCRIPTS_PATH'; private $for; private $fors; private $content; public function __construct($file) { if (file_exists($file)) $this->content = file_get_contents($file); else recordException("file: ".$file); } public function _var($name, $value) { $this->content = str_replace("{var:".$name."}", $value, $this->content); // $this->content = str_replace("[var:".$name."]", $value, $this->content); } public function _uservar($name, $value) { $this->content = str_replace("{uservar:".$name."}", $value, $this->content); $this->content = str_replace("%uservar:".$name."%", $value, $this->content); } public function _include($path, $filename, $convert=false) { $file = $path.$filename.".tmpl"; if (file_exists($file)) { $content = file_get_contents($file); if ($convert) $content = toDBCharset($content); $this->content = str_replace("{include:".$filename."}", $content, $this->content); } else { recordException("file: ".$file); } } public function _if($name, $cond=1) { if ($cond) $this->content = preg_replace("/{if:".$name."}(.*?){\/if:".$name."}/is", "\\1", $this->content); else $this->content = preg_replace("/{if:".$name."}(.*?){\/if:".$name."}/is", "", $this->content); } public function _userif($name,$v=1) { if ($v) $this->content = preg_replace("/{userif:".$name."}(.*?){\/userif:".$name."}/is", "\\1", $this->content); else $this->content = preg_replace("/{userif:".$name."}(.*?){\/userif:".$name."}/is", "", $this->content); } public function sFor($name) { unset($this->fors); $what = "{for:".$name."}(.*?){\/for:".$name."}"; preg_match("/".$what."/is", $this->content, $out); $this->for = $out[1]; } public function vFor($idx, $name, $value) { if ($this->fors[$idx]) $tmp = $this->fors[$idx]; else $tmp = $this->for; $this->fors[$idx] = str_replace("{for-var:".$name."}", $value, $tmp); } public function iFor($idx, $name, $cond=1) { if ($this->fors[$idx]) $tmp = $this->fors[$idx]; else $tmp = $this->for; if ($cond) $this->fors[$idx] = preg_replace("/{for-if:".$name."}(.*?){\/for-if:".$name."}/is", "\\1", $tmp); else $this->fors[$idx] = preg_replace("/{for-if:".$name."}(.*?){\/for-if:".$name."}/is", "", $tmp); } public function eFor($name) { $tmp = (is_array($this->fors) ? implode("", $this->fors) : ""); $what = "{for:".$name."}(.*?){\/for:".$name."}"; $this->content = preg_replace("/".$what."/is", str_replace("$", "\\$", $tmp), $this->content); unset($this->for); }
В 48 строке PHP: unset($this->fors); Лучше заменить на PHP: $this->fors = []; И должно ли там быть fors или for?
После замены 48 строчки и исчезла ошибка Notice: Undefined property: template::$fors, но остальные остались. Там должно быть fors.
Тогда остается заменить в 55 строке PHP: if ($this->fors[$idx]) на PHP: if (isset($this->fors[$idx]))
Это типа тэст и fors отвечает за ответы, а for за вопрос и если убрать fors на for то ошибка пропадает, но и выбор ответов тоже. --- Добавлено --- Все получилось. Спасибо большое.