June 2005
Intermediate to advanced
794 pages
18h 27m
German
Sie möchten einen Codeblock schützen, in dem verschiedene Klassen von Exceptions auftreten können. Sie möchten das Exception-Handling von der jeweiligen Klasse abhängig machen.
Verwenden Sie mehrere catch-Blöcke:
class EPriceException extends Exception { public $price; // Preis für den catch-Block erhalten. public function _ _construct($message, $code, $price) { parent::_ _construct($message, $code); $this->price = $price; } } class EPriceNotANumberException extends EPriceException { public function _ _construct($price) { parent::_ _construct("Price is not a number", 1, $price); } } class EPriceNegativeException extends EPriceException { public function _ _construct($price) { parent::_ _construct("Price ...Read now
Unlock full access