note 87009 modified in language.oop5.overloading by danbrown
| From: | danbrown@php.net | Date: | Fri, 14 Nov 2008 17:11:58 +0000 |
| Subject: | note 87009 modified in language.oop5.overloading by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146538@lists.php.net to get a copy of this message | ||
<?php
/***********************************************
*And here follows a child class which implements a menu based in the 'nodoMenu' class
(previous note).
*
*[]s
*
*erick2711 at gmail dot com
************************************************/
class menu extends nodoMenu{
private $cssc = array();
public function __toString(){ //Just to show, replace with something better.
$stringMenu = "<pre>\n";$stringMenu .= $this->strPrint();$stringMenu .=
"</pre>\n";
return $stringMenu;
}
public function __construct($cssn = null){
parent::__construct();
if (isset($cssn) && is_array($cssn)){$this->cssc = $cssn;}
$this->buildMenu();
}
public function buildMenu(){
$this->add('server',
'Server',
'server.php');
$this->server->add('personalD',
'Personal Data',
'server/personal.php');
$this->server->add('personalI',
'Personal Interviews',
'server/personalI.php');
$this->server->personalI->add('detailsByIer',
'Detalis by Interviewer',
'server/personalI.php?tab=detailsByIer');
//(...)
return $this;
}
}
//Testing
$meuMenu = new menu;
echo $meuMenu;
/***********************************************
*Will output (to the browser):
*
*<pre>
*1 Server<br>
*Â Â 1.1 Personal Data<br>
*Â Â 1.2 Personal Interviews<br>
*Â Â Â Â Â Â 1.2.1 Details by Interviewer<br>
*</pre>
*
*Which shows:
*
*1 Server
* 1.1 Personal Data
* 1.2 Personal Interviews
* 1.2.1 Details by Interviewer
************************************************/
?>
--was--
<?
/***********************************************
*And here folows a child class which implements a menu based in the 'nodoMenu' class
(previous note).
*
*[]s
*
*erick2711 at gmail dot com
************************************************/
class menu extends nodoMenu{
private $cssc = array();
public function __toString(){ //Just to show, replace with something better.
$stringMenu = "<pre>\n";$stringMenu .= $this->strPrint();$stringMenu .=
"</pre>\n";
return $stringMenu;
}
public function __construct($cssn = null){
parent::__construct();
if (isset($cssn) && is_array($cssn)){$this->cssc = $cssn;}
$this->buildMenu();
}
public function buildMenu(){
$this->add('server',
'Server',
'server.php');
$this->server->add('personalD',
'Personal Data',
'server/personal.php');
$this->server->add('personalI',
'Personal Interviews',
'server/personalI.php');
$this->server->personalI->add('detailsByIer',
'Detalis by Interviewer',
'server/personalI.php?tab=detailsByIer');
//(...)
return $this;
}
}
//Testing
$meuMenu = new menu;
echo $meuMenu;
/***********************************************
*Will output (to the browser):
*
*<pre>
*1 Server<br>
* 1.1 Personal Data<br>
* 1.2 Personal Interviews<br>
* 1.2.1 Details by Interviewer<br>
*</pre>
*
*Which shows:
*
*1 Server
* 1.1 Personal Data
* 1.2 Personal Interviews
* 1.2.1 Details by Interviewer
************************************************/
?>
http://php.net/manual/en/language.oop5.overloading.php