note 97815 modified in function.die by danbrown
| From: | danbrown@php.net | Date: | Mon, 10 May 2010 12:11:00 +0000 |
| Subject: | note 97815 modified in function.die by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169114@lists.php.net to get a copy of this message | ||
I was making a few functions and i thought it would be easier to use a single function to close off
my code, The following is a example of it working i am sure if you include footer code when exiting
code all the time you'll understand the purpose of the following function.
<?php
function error_msg($text) {
# add other stuff you may want here
$hello_var = 'hello'; //example of addon to beginning
$goodbye_var = 'goodbye'; //example of addon to end
die($hello_var.'<br />'.$text.'<br />'.$goodbye_var);
}
error_msg('how are you?');
?>
Outputs:
hello
how are you?
goodbye
[EDIT BY danbrown AT php DOT net: Contains a minor bugfix provided by (zero DOT effect AT hotmail
DOT com) on 10-MAY-2010.]
--was--
I was making a few functions and i thought it would be easier to use a single function to close off
my code, The following is a example of it working i am sure if you include footer code when exiting
code all the time you'll understand the purpose of the following function.
<?php
function error_msg($text) {
# add other stuff you may want here
$hello_var = 'hello'; //example of addon to beginning
$goodbye_var = 'goodbye'; //example of addon to end
die($hello_var.'<br />'.$text.'<br />'.$goodbye_var);
}
echo error_msg('how are you?');
?>
Outputs:
hello
how are you?
goodbye
http://php.net/manual/en/function.die.php