Copy code The code is as follows:
$data = array(
‘title’=>'ilsea',
'list' = & gt; array (
'hello',
'world'
);
Include ('show.php');
// show.php template file
echo $data['title'];
echo '
';
print_r($data['list']);
?>
Define a function to contain the template and pass the data
Copy code The code is as follows:
// Define a function to contain the template and pass data. It should be defined in the public function library. Here I will write it directly here
function template($template,$data)
{
if(isset($data)){
foreach($data as $key=>$ val){
$$key = $val;
}
unset($data);
}
include($template);
}
template ('show.php',$data);
This example is of course not a complete writing method, it is just a small example. This is the principle of template assignment.
http://www.bkjia.com/PHPjc/825173.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825173.htmlTechArticleCopy the code The code is as follows: $data = array( 'title'='ilsea', 'list'=array( 'hello', 'world' ) ); include('show.php'); // show.php template file div ?php echo $data['title']; echo 'br/...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn