Re: How do I return the error

From: Date: Wed, 28 Jul 2004 14:07:00 +0000
Subject: Re: How do I return the error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-192097@lists.php.net to get a copy of this message
what about returning the error the copy function would have thrown ? Thanks ----- Original Message ----- From: "John Nichel" <john@kegworks.com> To: <php-general@lists.php.net> Sent: Wednesday, July 28, 2004 3:00 PM Subject: Re: [PHP] How do I return the error > Matthew Oatham wrote: > > Hi I have this function below - if it reurns false I want to also return the error so I can print it in my calling function. Can I do this? > > > > Cheers > > > > Matt > > > > function fileUpload($file) { > > if ($file['type'] == "image/gif" || $file['type'] == > > "image/pjpeg"){ > > if (@copy ($file['tmp_name'], "images/" . > > $file['name'])) > > return true; > > }else { > > return false; > > } > > } > > > > $error = ""; > function fileUpload($file) { > global $error; > if ($file['type'] == "image/gif" || $file['type'] == > "image/pjpeg"){ > if (@copy ($file['tmp_name'], "images/" . $file['name'])) > return true; > }else { > $error = "Something went wrong"; > return false; > } > } > > if ( ! fileUpload ( $file ) ) { > echo ( $error ); > } > > Course, there are numerous other ways of doing this. I persoanlly use > two custom functions to handle/display errors. > > -- > John C. Nichel > ÜberGeek > KegWorks.com > 716.856.9675 > john@kegworks.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#192097) next »