Destroy a session var passed as an argument
| From: | Julio Nobrega Trabalhando | Date: | Wed, 24 Apr 2002 18:59:04 +0000 |
| Subject: | Destroy a session var passed as an argument | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-94432@lists.php.net to get a copy of this message | ||
Hi All!
I have a simple function that returns a message:
function showError ($mensagem)
{
return '<div class="erro">' . $mensagem . '</div>';
}
And this is how I use it:
if (isset($_SESSION['forum']['error']['insert'])) {
echo showError($_SESSION['forum']['error']['insert']));
}
But I want that when the function is used the session variable is
destroyed. A simple unset($mensagem) inside showError() gives me back this:
Warning: Undefined variable: mensagem in
c:\www\lib\sistema\formularios\formularios.inc.php on line 92
I would not like to put an unset() inside if (isset($_SESSION....)), after
the function is called, since that only adds another line in my script, and
['error'] is an array with several other values. I have tried passing it as
a reference the function argument but the error persists.
So:
How can I destroy the session variable inside showError($_SESSION)?
Thanks for any tips,
--
Julio Nobrega.