Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Declare the interface 'iTemplate'
- interface iTemplate
- {
- public function setVariable($name, $var);
- public function getHtm($template);
- }
- //Implement the interface
- //This will work
- class Template Implements iTemplate
- {
- private $vars = array();
- public function setVariable($namae, $var)
- {
- $this->vars[$name] =$var;
- }
- public function getHtm($template)
- {
- foreach($this->vars as $name => $value){
- $Template = str_replace('['. $name . ']', $value, $Template);
- }
- return $Template;
- }
- }
- //This will not work
- //Fatal error: Class BadTemplate contains 1 abstrack methods
- //and must therefore be declared abstract(iTemplate::getHtm)
- class BadTemplat Implements iTemplate
- {
- private $vars = array();
- public funcation setVariable($name, $var)
- {
- $this->vars[$name] = $var;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement