Posted by Ian Davies on 05/30/06 18:07
thanks
will make a note of that one
ian
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:cf8d1$447c85af$8259c69c$30997@news2.tudelft.nl...
> Ian Davies wrote:
> >> $_SESSION[key] = (isset($_POST[key])) ? trim($_POST[key]) :
> >> $_SESSION[key];
> > Your a saviour Rik cheers
> > Works a treat.
> > out of interest what is the script doing? I cant work it out
>
> Search www.php.net for ternary operator:
> http://nl2.php.net/manual/en/language.operators.comparison.php
>
> Actually, it does the following:
>
> if(isset($_POST[key]){ //checks wether a new $_POST value with the
specific
> key exists
> $_SESSION[key] = trim($_POST[key]); //sets the session value to the
> posted value
> } else {
> $_SESSION[key] = $_SESSION[key]; //keep the session variable the same
as
> it was
> }
>
> The ternary operator just saves a lot of lines in the code while doing
> simple checks.
>
> Grtz,
> --
> Rik Wasmus
>
>
[Back to original message]
|