raman Posted November 7, 2008 Share Posted November 7, 2008 Can someone tell me the meaning of the following code : $jobid = (empty($_GET['jobid'])) ? '' : $_GET['jobid']; if (!$jobid) { $jobid = time(); } $blastdb = (empty($_POST['blastdb'])) ? '' : $_POST['blastdb']; $blastpath = (empty($_POST['blastpath'])) ? '' : $_POST['blastpath']; $patientIDarray = (empty($_POST['patientIDarray'])) ? '' : $_POST['patientIDarray']; $opt = (empty($_GET['opt'])) ? '' : $_GET['opt']; Basically I want to know WHAT IS BEING DONE FOR EVERY VARIABLE ? what is the meaning of ? : characters ? I guess this says that either the variable coming from the post method is empty or it is equal to its value.Please clarify ! Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/ Share on other sites More sharing options...
raman Posted November 7, 2008 Author Share Posted November 7, 2008 Please explain the jobid variable at length.I guess The code says that if it is empty coming from get method or it has a value or if it is neither of these then assign the value of time() function to it. Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684403 Share on other sites More sharing options...
ratcateme Posted November 7, 2008 Share Posted November 7, 2008 ? : is a simplified if else statement so $vara = 5; $var = $vara == 5 ? "Is five" : "Is not five"; //is the same as if($var2 == 5){ $var = "Is five"; }else{ $var = "Is not five"; } Scott. Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684406 Share on other sites More sharing options...
Zane Posted November 7, 2008 Share Posted November 7, 2008 also called a ternary statement Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684413 Share on other sites More sharing options...
raman Posted November 7, 2008 Author Share Posted November 7, 2008 Thanks I understand it now. Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684450 Share on other sites More sharing options...
raman Posted November 7, 2008 Author Share Posted November 7, 2008 Please explain the $jobid variable. What my code says is tht if $_GET['jobid') is emppty then $jobid= '' else it is $_GET['jobid'] . But after this the code says if (!$jobid) { $jobid = time(); } What is happening here ? Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684451 Share on other sites More sharing options...
Mchl Posted November 7, 2008 Share Posted November 7, 2008 if (!$jobid) { $jobid = time(); } This code checks if $jobid is empty string ( '' ) or a '0' and if so, then assigns it a value of time() (I assumed that at this stage $jobid will be a string after going through ?: Link to comment https://forums.phpfreaks.com/topic/131758-solved-maeaning-of-in-php/#findComment-684454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.