خطأ برمجي لا افهم سببه

السلام عليكم

من المفروض اني اعمل ع محرك قوالب , ومن خلال التعابير القياسية اضيف الحالة الشرطية للمحرك , هنا سطر الكود :

                // تحويل كل ما هو داخل <if con=""> الي شرط   
        $this->output = preg_replace('/<if con="(.*)"\s*>/i','<?php if($1){ ?>',$this->output);

            // إغلاق الشرط  
        $this->output = preg_replace('/<\/if>/i','<php } ?>',$this->output);

لكن في حالة تجربة الاداء يظهر الخطأ :

Parse error: syntax error, unexpected end of file in C:\wamp\www\ht.html on line 366

مع العلم ان السطر 36 في الاصل هو وسم اغلاق الـ html

فهل من اي تفسير !؟


اسف ع التأخير , بعد عدد من المحاولات ظهر خطأ جديد وهو :

Parse error: syntax error, unexpected '<' in C:\wamp\www\ht.html on line 23

هنا اكواد القالب بالكامل :

<?php

CLASS W3_TEMPLATE{

var $cache; // مجلد الكاش  
var $variable; // مصفوفة المتغيرات العامه في النظام  
var $output; // المخرجات  
var $input; // المدخلات  
var $temp;// مكان القوالب  

// التحقق من اصدار PHP واعداد القيم
public function __CONSTRUCT($template,$cache){

    if(phpversion() < '5.0.0') die("Error : Please Upgrade Your PHP To 5.0.0 Or later"); // التحقق من اصدارPHP
    $this->temp = $template; // متغير مجلد القوالب
    $this->cache = $cache; // مجلد متغير الكاش
    $this->variable = $GLOBALS;

}#Close function constructor

// دالة جلب القوالب
public function GET_TEMPLATE($filename){

    if(!file_exists($this->temp)) die("Error: the folder ".$this->temp." is not found"); //التحقق من وجود مجلد القوالب
    if(!file_exists($this->temp.'/'.$filename)) die("Error: ".$this->temp.'/'.$filename." is not found");//التحقق من وجود القالب المطلوب
    $this->input = file_get_contents($this->temp.'/'.$filename); // استعداء القالب
    return $this->input;

}#Close function GET_TEMPLATE


// التحقق من اجراء اي تعديلات ع القالب
public function chack_size($filename){

    $chack = @fopen($filename,r);
    $read  = @fread($chack,@filesize($filename));
    @fclose($chack);
    return $read;
}#Close Function chack size

// معالجة اكواد القالب الى php
public function replace_var(){

        // تغير كل ما هو بين {} الي متغير عام  
    $this->output = preg_replace('/{(.*)}/','<?php echo $this->variable[\'$1\']; ?>',$this->input);   
        // عمل  جلب داخلي  للقوالب عن طريق دالة ouput سنعرضها بعد قليل 
    $this->output = preg_replace('/<!--include:(.*)-->/','<?php $this->output(\'$1\');?>',$this->output);  

        // تحويل كل ما هو داخل <if con=""> الي شرط   
    $this->output = preg_replace('/<if con="(.*)"\s*>/i','<?php if($1){ ?>',$this->output);

        // إغلاق الشرط  
    $this->output = preg_replace('/<\/if>/i','<?php } ?>',$this->output); 


            return $this->output; // الرجوع بالتعديلات كمخرجات   
}#Close Function Replace Var



// الداله تأخذ  مدخل  واحد و هو اسم  ملف  القالب  
public function display($filename){


            //تحويل كل العلامه / الي - حتي  لا يتم استغلالها في  جلب ملفات خارج مجلد القوالب       
    $filename = str_replace('/','-',$filename);

            //استدعاء القالب   
    $this->GET_TEMPLATE($filename);

            // معالجة الاكواد وتحويلها الى php  
    $html = $this->replace_var();  

            //استخدام الخاصيه كاش التي تحمل اسم  مجلد الكاش و اسم الملف  المدخل حتي  نقوم  بجلبه فيما  بعد   
    $name = "$this->cache/$filename.php";

            // فتح الملف في  مجلد الكاش للتأكد من ان الملف به  تغيرات حتي نقوم بعمل التعديلات عليه  
    $check = $this->chack_size($name);  

        // التأكد من انه يوجد اختلاف  بين المدخلات و المخرجات حتي  نقوم بالتعديل  
    if($check != $html){  
            // التعديل علي ملف القالب داخل الكاش بالتعديلات التي تم عملها  
     $file = @fopen($filename,w);  
     $write = @fwrite ($file,$html);  
     @fclose($file);  
        }  

            // جلب الملف من داخل مجلد الكاش  
   include_once("$filename");  

}#Close function Display

}#Close class W3


هنا اكواد ملف الـ Html :

<!DOCTYPE html>

    <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
    Remove this if you use the .htaccess -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>HTML</title>
    <meta name="description" content="">
    <meta name="author" content="mohammedshaker">

    <meta name="viewport" content="width=device-width; initial-scale=1.0">

    <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
</head>

<body>

            <if con="{mm} == 1" >

      true  
    </if>


</body>