create-your-own-php-framework icon indicating copy to clipboard operation
create-your-own-php-framework copied to clipboard

写的挺好的。

Open shalao opened this issue 6 years ago • 1 comments

十二章,Compiler类中

public function compile($file = null, $params = []) {
$path = '../views/'.$file.'.sf'; extract($params); if (!$this->isExpired($path)) { $compiled = $this->getCompiledPath($path); require_once $compiled;

          return;
      }   
      $fileContent = file_get_contents($path);
      $result = ''; 
      foreach (token_get_all($fileContent) as $token) {
          if (is_array($token)) {
              list($id, $content) = $token;
              if ($id == T_INLINE_HTML) {
                  foreach ($this->compilers as $type) {
                      $content = $this->{"compile{$type}"}($content); //这个是不是改成拼接呢 $content .= $this->{"compile{$type}"}($content); 
                  }   
              }   
              $result .= $content;
          } else {
              $result .= $token;
          }   
      }   
      $compiled = $this->getCompiledPath($path);
      file_put_contents($compiled, $result);
      require_once $compiled;
  }   

shalao avatar Mar 16 '19 14:03 shalao

十二章,Compiler类中

public function compile($file = null, $params = []) {
$path = '../views/'.$file.'.sf'; extract($params); if (!$this->isExpired($path)) { $compiled = $this->getCompiledPath($path); require_once $compiled;

          return;
      }   
      $fileContent = file_get_contents($path);
      $result = ''; 
      foreach (token_get_all($fileContent) as $token) {
          if (is_array($token)) {
              list($id, $content) = $token;
              if ($id == T_INLINE_HTML) {
                  foreach ($this->compilers as $type) {
                      $content = $this->{"compile{$type}"}($content); //这个是不是改成拼接呢 $content .= $this->{"compile{$type}"}($content); 
                  }   
              }   
              $result .= $content;
          } else {
              $result .= $token;
          }   
      }   
      $compiled = $this->getCompiledPath($path);
      file_put_contents($compiled, $result);
      require_once $compiled;
  }   

Pnmrayong avatar Nov 22 '24 14:11 Pnmrayong