#38544 [Fbk->Opn]: tryeach

From: Date: Tue, 22 Aug 2006 13:20:35 +0000
Subject: #38544 [Fbk->Opn]: tryeach
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101113@lists.php.net to get a copy of this message
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] tony2001@php.net 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

« previous php.bugs (#101113) next »