Reply to Re: unable to retain values in text box

Your name:

Reply:


Posted by Rik on 05/30/06 17:50

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация