ID: 38544
User updated by: dtyschenko at soft-ukraine dot com
Reported By: dtyschenko at soft-ukraine dot com
-Status: Feedback
+Status: Open
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 5.1.5
New Comment:
The keyword is each.
When user submit the form, you show them waht he misses. With try you
will show only one error.
And with tryeach all errors.
Previous Comments:
------------------------------------------------------------------------
[2006-08-22 12:25:56] [EMAIL PROTECTED]
What's the problem with this ?
try {
$Item->Title($_POST['title']);
$Item->Content($_POST['content']);
} ...
------------------------------------------------------------------------
[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