note 90882 added to function.halt-compiler
| From: | Ultimater at gmail dot com | Date: | Thu, 14 May 2009 13:36:18 +0000 |
| Subject: | note 90882 added to function.halt-compiler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154594@lists.php.net to get a copy of this message | ||
Another possible usage, in addition to binary data and installers,
is using it to separate model, view and controller logic from one another:
<?php
class viewhelper{function render(){
eval(file_get_contents(__FILE__,null,null,__COMPILER_HALT_OFFSET__));
}}
//database logic goes here
$row=array(
'loggedin'=>true,
'modcp'=>true,
'admincp'=>false,
'username'=>'Ultimater',
'userid'=>1234
);
//database logic goes here
//controller logic goes here
$view=new viewhelper;
$view->title="Test -> Ultimater's MVC example";
$view->base="http://".$_SERVER['HTTP_HOST'];
$view->username=$row['username'];
$view->userid=$row['userid'];
$view->authbar->loggedin=$row['loggedin'];
$view->authbar->modcp=$row['modcp'];
$view->authbar->admincp=$row['admincp'];
$view->render();
//controller logic goes here
__halt_compiler();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=htmlentities($this->title)?></title>
<style type="text/css">
a{color:#3333ff;text-decoration:none;}
a:hover{color:#0380fc;}
</style>
</head>
<body>
<?php
if($this->authbar->loggedin){
?>
<table><tr>
<td>Hello <a
href="<?=$this->base?>/showuser.php?id=<?=$this->userid?>
"><?=htmlentities($this->username)?></a></td><td>[</td>
<td><a href="<?=$this->base?>/logout.php">Log
Out</a></td>
<th><a href="<?=$this->base?>/usercp.php">UserCP</a></th>
<? if($this->authbar->modcp){ ?>
<td>·</td><th><a
href="<?=$this->base?>/modcp.php">ModCP</a></th>
<? } ?>
<? if($this->authbar->admincp){ ?>
<td>·</td><th><a
href="<?=$this->base?>/admincp.php">AdminCP</a></th>
<? } ?>
<td>]</td>
</tr></table>
<?php
}else{
?>
<table><tr><td>Hello Guest</td><td>[</td>
<td><a href="<?=$this->base?>/login.php">Log In</a></td>
<th><a
href="<?=$this->base?>/register.php">Register</a></th>
<td>]</td></tr></table>
<? } ?>
</body>
</html>
----
Server IP: 66.207.199.35
Probable Submitter: 76.94.233.193
----
Manual Page -- http://www.php.net/manual/en/function.halt-compiler.php
Edit -- https://master.php.net/note/edit/90882
Del: integrated -- https://master.php.net/note/delete/90882/integrated
Del: useless -- https://master.php.net/note/delete/90882/useless
Del: bad code -- https://master.php.net/note/delete/90882/bad+code
Del: spam -- https://master.php.net/note/delete/90882/spam
Del: non-english -- https://master.php.net/note/delete/90882/non-english
Del: in docs -- https://master.php.net/note/delete/90882/in+docs
Del: other reasons-- https://master.php.net/note/delete/90882
Reject -- https://master.php.net/note/reject/90882
Search -- https://master.php.net/manage/user-notes.php