Explanation of PHP template principles_PHP tutorial

WBOY
Release: 2016-07-13 10:25:14
Original
716 people have browsed it

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.

www.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/...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!