note 56485 deleted from language.oop5 by aidan
| From: | aidan@php.net | Date: | Mon, 05 Sep 2005 06:10:49 +0000 |
| Subject: | note 56485 deleted from language.oop5 by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94739@lists.php.net to get a copy of this message | ||
Note Submitter: arek at dardo dot pl
Reason: useless
----
In regards to hans at lintoo dot dk
When you need give different type of param(s):
<?php
class ABC{
public function __construct($param=null) {
switch(gettype($param)){
case 'integer':
// do something with integer
// example run $this->start_with_string($param);
break;
case 'string':
// do something with string
// example run $this->start_with_int($param);
break;
default:
throw new Exception("Error: __construct called with wrong type (only string *OR*
int)");
}
}
}
$a = new ABC('text'); // works with string field
$b = new ABC(4); // works with intereg field
Arek Macak
?>