подскажите в чем может быть проблема. есть файл index.php Код (Text): <?php /** * Created by PhpStorm. * User: VasilyevAB * Date: 10.12.2014 * Time: 11:11 */ include "/lib/config_class.php"; header('Content-type: text/html; charset: utf-8'); $tmp = file_get_contents(Config::TPL_PATH."/index.tpl"); $title = Config::TITLE; $stile = Config::STYLE_PATH; #$header = file_get_contents(Config::TPL_PATH."/header.tpl"); $header = '<header> <div class="header"> <div class="search"> </div> </div> </header>'; $tmp = mb_ereg_replace("%header%", $header, $tmp); $tmp = mb_ereg_replace("%title%", $title, $tmp); $tmp = mb_ereg_replace("%style_path%", $stile, $tmp); echo $tmp; в таком виде все отображается нормально, но если загружать этот фрагмент Код (Text): $header = '<header> <div class="header"> <div class="search"> </div> </div> </header>'; из шаблона ( Код (Text): $header = file_get_contents(Config::TPL_PATH."/header.tpl"); ) то в html перед тегом <header> появляются 2 двойные кавычки
это пхп код присваивающий переменной текстовое значение. это чтение содержимого файла. побайтово. в этой переменной $header по идее лежит текст из листинга выше. если вы хотите объявление переменной то шаблон должен быть не .tpl а .php и подключаться через include а не file_get_contents. если вы хотите в шаблоне оставить только "чистый" html - уберите php-инструкции из своего .tpl. и повысьте уровень отладки и включите вывод ошибок на экран - двойные кавычки могут неожиданно на что-то намекать.
проблема решилась Код (Text): ini_set('display_errors',1); error_reporting(E_ALL); date_default_timezone_set("Europe/Moscow"); include "/lib/config_class.php"; header('Content-type: text/html; charset: utf-8'); $tmp = file_get_contents(Config::TPL_PATH."/index.tpl"); $title = Config::TITLE; $stile = Config::STYLE_PATH; $a = '1'; $b = '2'; $tmp1 = $header = file_get_contents(Config::TPL_PATH."/header1.tpl"); #$tmp1 = str_replace('<', $a, $tmp1); #$tmp1 = str_replace(">", $b, $tmp1); $header = file_get_contents(Config::TPL_PATH."/header1.tpl"); $header = stristr($header, "<"); Код (Text): $tmp = str_replace("%header%", $header, $tmp); $tmp = str_replace("%title%", $title, $tmp); $tmp = str_replace("%style_path%", $stile, $tmp); echo $tmp;