Click to See Complete Forum and Search --> : need help on trim and conditional statement


Nacirema
11-28-2006, 09:25 AM
$_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


Also does anyone know how to lower PHP warning levels on IIS 5.1?

chickenland
11-28-2006, 09:34 AM
$_REQUEST['statement'] = (trim($_REQUEST['statement']) != "" ? $_REQUEST['statement'] : $_LANG['Nostatement']);


its an if, then, else statement


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

Nacirema
11-28-2006, 09:53 AM
ok, so this doesn't do an actual trim as such

this isn't the line doing the truncating as far as output is concerned?

chickenland
11-28-2006, 09:57 AM
it just checks if the trimmed value = '', it doesn't actually trim

Nacirema
11-28-2006, 10:14 AM
ok thanks
i need to find out where the trimming occurs
do u see any here?

if($_REQUEST['rejectStatement']){
$_REQUEST['statement'] = (trim($_REQUEST['statement']) != "" ? $_REQUEST['statement'] : $_LANG['noStatement']);
$quotDAO->setQuotationRejected(base64_decode($_REQUEST['qId']), $_REQUEST['statement']);
$statement = $_LANG['quotationRejected'];
$stat = base64_encode("<img src='./img/dot_green.gif' align='absmiddle'> ".$statemntQT);
if($_REQUEST['notify']){
$quot = $quotDAO->initializeQuotation(base64_decode($_REQUEST['qId']));
$quot->quotConfirmation = 1;
$quotDAO->sendNotification($quot->vendor, $_LANG['subjectRejected'],
"<br>".$_LANG['bodyRejected']."<br><br>"
.$_REQUEST['statement']."<br><br>".
$quotHTML->wrap($quotHTML->showQuotationFormTemplate($quot), 0, 10));
}


If you are wondering what some of those functions are:


class QuotationHTML {

var $lang;
var $edit;
var $readonly;
var $disabled;

function QuotationHTML(){
global $_LANG;
$this->lang = $_LANG;

require_once(ABS_APP_PATH."src//StatemntQT.php");
//include css and javascript
if($statement){
echo "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td align='left'>".$statemntQT."</td></tr></table>";
}
/*.
"<link href='./css/style.css' rel='stylesheet' type='text/css'>
<SCRIPT src='./js/functions.js' type=text/javascript></SCRIPT>";*/
}

function echoHTMLTemplate($html){
return $html;
}


and this is the wrap you see

function wrap($content, $border='0', $cellspace='0', $cellpadd='0'){
$html = "
<table border='".$border."' cellspacing='".$cellspace."' cellpadding='".$cellpadd."'>
<tr>
<td>"
.$content."
</td>
</tr>
</table>";
return $html;
}

bokeh
11-28-2006, 01:37 PM
if (trim($_REQUEST['statement']) != ""){
$_REQUEST['statement'] = $_REQUEST['statement'];}
else{$_REQUEST['statement'] = $_LANG['Nostatement']);}I would write that as follows:if(($_REQUEST['statement'] = trim($_REQUEST['statement'])) === "")
{
$_REQUEST['statement'] = $_LANG['Nostatement']);
}Also you might consider adding a test to see if the variable exists.