1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
<?php
class maClass
{
var $_options;
function __construct($param1 = 'pwet', $param2 = true, $param3 = 2)
{
$this->_options = array();
$this->_options['param1'] = $param1;
$this->_options['param2'] = $param2;
$this->_options['param3'] = $param3;
}
function maClass($param1 = 'pwet', $param2 = true, $param3 = 2)
{
$this->__construct($param1, $param2, $param3);
register_shutdown_function(array(&$this,'__destruct'));
}
function __destruct() { }
function setOptions($options)
{
if(empty($options))
return true;
$noError = true;
foreach($otions as $option => $value)
{
if(!$this->setOption($option,$value))
$noError = false;
}
return $noError;
}
function setOption($option,$value)
{
if(isset($this->_options[$option]))
{
$this->_options[$option] = $value;
return true;
}
return false;
}
function display()
{
if($this->_options['param2'])
{
for($i=0;$i<$this->_options['param3'];++$i)
echo $this->_options['param1'].'<br />';
}
else echo $this->_options['param1'].'<br />';
}
}
?> |
Partager