...

View Full Version : can someone help me with this trim and conditional statement



LondonBoy
11-28-2006, 03:15 PM
$_REQUEST['statement'] = (trim($_REQUEST['statement']) != "" ? $_REQUEST['statement'] : $_LANG['Nostatement']);

Hi all,

Can someone tell me what the above is doing? Statement is always truncated in output, obviously because of trim, but what does the whole statement do?

Can i just take out trim?
Is the trim the problem, i thought it only takes out whitespaces.

marek_mar
11-28-2006, 03:25 PM
It is the equivalent of:



if((trim($_REQUEST['statement']) != "")
{
$_REQUEST['statement'] = $_REQUEST['statement'];
}
else
{
$_REQUEST['statement'] = $_LANG['Nostatement'];
}

The ?: is called a ternary operator.
BTW The code should check if $_REQUEST['statement'] is actaully set before doing things with it.

LondonBoy
11-28-2006, 03:55 PM
yes ur right

so this isn't the line of code truncating output?

marek_mar
11-28-2006, 05:08 PM
No, the value is trimmed for comparison. But it's not changed if the trimmed value is not an empty string.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum