start使用介绍(3)


//@file:user-profile.tpl.php
<div>
     <ul>
          <li>username: <?php echo $user->name; ?></li>
          <li>picture:<?php echo $user->picture; ?></li>
     </ul>
</div>

//@file:template-render.php
<?php
function theme_render_template($template_file, $variables) {
  if (!<a href="https://www.php.net/is_file">is_file</a>($template_file) { return ""; }
  <a href="https://www.php.net/extract">extract</a>($variables, EXTR_SKIP);
  <a href="https://www.php.net/ob_start">ob_start</a>();
  $contents = <a href="https://www.php.net/ob_get_contents">ob_get_contents</a>();
  <a href="https://www.php.net/ob_end_clean">ob_end_clean</a>();
  return $contents;
}
?>

//@file:profile.php
<?php
$variables = <a href="https://www.php.net/array">array</a>('user' => $user);
print theme_render_template('user-profile.tpl.php', $variables);
?>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/8b1add326aa3ba46ba7d99fb6b3506a4.html