|
|
|
|
|
|
|
|
|
Like this code?
Show the author your appreciation.
|
| |
| <?php
function View($view)
{
if (is_file('./' . $view . '.php') === true)
{
for ($i = 1; $i < func_num_args(); $i++)
{
$argument = func_get_arg($i);
if (is_array($argument) === true)
{
extract($argument, EXTR_OVERWRITE);
}
}
require('./' . $view . '.php');
}
return false;
}
?> | |
Usage:
| <?php
$data = array
(
'title' => 'Hello World!',
'heading' => 'Welcome';
'content' => '...',
'list' => array('do this', 'do that', 'and dont forget...!'),
);
View('/path/to/view', $data);
?>
Contents of /path/to/view.php:
<html>
<head>
<title><?= $title;?></title>
</head>
<body>
<h1><?= $heading; ?></h1>
<p><?= $content; ?></p>
<ul>
<?php foreach ($list as $item): ?>
<li><?= $item; ?></li>
<?php endforeach; ?>
</ul>
</body>
</html> | | |
|
| PHP template processing Categories : PHP, Templates, HTML and PHP | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Website Engine Categories : PHP, HTML and PHP, Templates | | | Calendar using Date function Categories : HTML and PHP, PHP, Date Time, Calendar | | | Save time debugging PHP3 under UNIX/Linux using linked .phps files Categories : HTML and PHP, Debugging, PHP | | | PageRank Display Categories : Search Engines, HTML and PHP, PHP | | | mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases | | | Print out array key => value in colored HTML Categories : PHP, Arrays, HTML and PHP | | | XTemplate, a template class for PHP Categories : PHP Classes, HTML and PHP, PHP | | | Upload Script, Upload File Script, Input Type="File" Categories : PHP, HTML and PHP, HTTP | | | The Nearly Perfect Contact Us Form Categories : PHP, Form Processing, HTML and PHP | | | This script shows you the 7th latest php items from the mailing list archive on zend.com Categories : HTML, HTML and PHP, HTTP, PHP | | | AITSH Statistics Categories : Complete Programs, Databases, HTML and PHP, Sessions, PHP | | | Parse html (title :: meta) Categories : PHP, HTML and PHP, Regexps | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | |
| |
| |
|