//@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);
?>
您可能感兴趣的文章: