php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24818 This is best php template
Submitted: 2003-07-26 08:07 UTC Modified: 2003-07-26 10:53 UTC
From: springchun at 21cn dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: springchun at 21cn dot com
New email:
PHP Version: OS:

 

 [2003-07-26 08:07 UTC] springchun at 21cn dot com
Description:
------------
This is best php template than Smarty,FastTemplate and PHPLIB Template;
Is it add this function into php5.0.dll?
please seen 'http://www.cqlc.net/document.txt';
function cqlctpl($file)
            {
            $fp=fopen($file,"r");
            $msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
            fclose($fp);
            $oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
                          1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
                          2=>"/\{exec:([^\}]+)\}/si",
                          3=>"/(\{\*[^\*]+\*\})/si"
                         );
            $newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
                          1=>"\";\\1{echo\"\\2\";}echo\"",
                          2=>"\";\\1;echo\"",
                          3=>""
                         );
            return preg_replace($oldstr,$newstr,$msg);
            }


Reproduce code:
---------------
<?
   function cqlctpl($file)
            {
            $fp=fopen($file,"r");
            $msg="echo\"".str_replace("\"","\\\"",fread($fp,filesize($file)))."\";";
            fclose($fp);
            $oldstr=array(0=>"/\{loop:([^\}]+)\}(.+)\{\/loop\}/si",
                          1=>"/\{logi:([^\}]+)\}(.+)\{\/logi\}/si",
                          2=>"/\{exec:([^\}]+)\}/si",
                          3=>"/(\{\*[^\*]+\*\})/si"
                         );
            $newstr=array(0=>"\";\\1{echo\"\\2\";}echo\"",
                          1=>"\";\\1{echo\"\\2\";}echo\"",
                          2=>"\";\\1;echo\"",
                          3=>""
                         );
            return preg_replace($oldstr,$newstr,$msg);
            }

  function test(){echo"<p>this is 2.tml ,welcome you";}

  $title="this is a tml";

  $body="this out ";

  for($i=0;$i<10;$i++)$array[$i]="hello world $i";

  eval(cqlctpl("1.txt"));



Expected result:
----------------
this is a tml (1.tml) 
  this out is hello world 0 

  this out is hello world 1 

  this out is hello world 2 

  this out is hello world 3 

  this out is hello world 4 

  this out is hello world 5 

  this out is hello world 6 

  6 is biger than 5 

  this out is hello world 7 

  7 is biger than 5 

  this out is hello world 8 

  8 is biger than 5 

  this out is hello world 9 

  9 is biger than 5 

  time is 1059193623 

  this is other tml(2.tml)
  this is 2.tml ,welcome you 


Actual result:
--------------
this is a tml (1.tml) 
  this out is hello world 0 

  this out is hello world 1 

  this out is hello world 2 

  this out is hello world 3 

  this out is hello world 4 

  this out is hello world 5 

  this out is hello world 6 

  6 is biger than 5 

  this out is hello world 7 

  7 is biger than 5 

  this out is hello world 8 

  8 is biger than 5 

  this out is hello world 9 

  9 is biger than 5 

  time is 1059193623 

  this is other tml(2.tml)
  this is 2.tml ,welcome you 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-26 10:53 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

not a PHP bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 09:01:33 2025 UTC