#38544 [Opn->Fbk]: tryeach
| From: | tony2001@php.net | Date: | Tue, 22 Aug 2006 12:25:57 +0000 |
| Subject: | #38544 [Opn->Fbk]: tryeach | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101108@lists.php.net to get a copy of this message | ||
ID: 38544
Updated by: tony2001@php.net
Reported By: dtyschenko at soft-ukraine dot com
-Status: Open
+Status: Feedback
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 5.1.5
New Comment:
What's the problem with this ?
try {
$Item->Title($_POST['title']);
$Item->Content($_POST['content']);
} ...
Previous Comments:
------------------------------------------------------------------------
[2006-08-22 12:16:35] dtyschenko at soft-ukraine dot com
Description:
------------
Sometimes I need to run few functions that can throw new exception
Reproduce code:
---------------
<?php
$errors = array();
try {
$Item->Title($_POST['title']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
try {
$Item->Content($_POST['content']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
// In this case tryeach operator can be very usefull
tryeach {
$Item->Title($_POST['title']);
$Item->Content($_POST['content']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38544&edit=1