Page 1 of 1
assigning either/or values
Posted: Thu Sep 20, 2007 8:00 am
by mad_phpq
hi, i've seen this somewhere before, but how can i put this onto one line?
Code: Select all
$value = $_POST['value'];
if ( $value = '' )
$value = $_GET['value'];
Posted: Thu Sep 20, 2007 8:03 am
by maliskoleather
Code: Select all
$value = empty($_POST['value'])?NULL:$_POST['value'];
Posted: Thu Sep 20, 2007 8:08 am
by mad_phpq
great! thanks. I take it is has to be
Code: Select all
$value = empty($_POST['value'])?NULL:$_GET['value'];
Posted: Thu Sep 20, 2007 8:15 am
by maliskoleather
its just easier to me that way..
it just needs to be
var = (logic or function)? true value : false value;
ofcourse, thats assuming your function in the logic area returns a boolean
