note 60205 added to function.die

From: Date: Thu, 29 Dec 2005 20:48:52 +0000
Subject: note 60205 added to function.die
Groups: php.notes 
Request: Send a blank email to php-notes+get-100953@lists.php.net to get a copy of this message
It's very useful on websites to have all your code in functions, then use "return" instead of die. For example: function log_in() { if(!isset($_POST[password])) { print "You must supply a password."; return; } // rest of the login function here } This way it exits out of the function, gives an error message, but doesn't keep the website from finishing loading. ---- Manual Page -- http://www.php.net/manual/en/function.die.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60205 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60205&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60205&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100953) next »