...

View Full Version : Some help with syntax



samuurai
09-22-2009, 04:33 PM
Hi,

I've got a function which has is set up like this:


function login($username, $password, $remember = false)


I want to somehow call this function like this (in pseudo code):


login($username,$password,if($_POST['remember']) evaluate to "true")

Can this be done?

Thanks!

MattF
09-22-2009, 04:38 PM
login($username,$password, ((isset($_POST['remember']) && intval($_POST['remember']) == '1') ? true : false));

samuurai
09-22-2009, 04:52 PM
login($username,$password, ((isset($_POST['remember']) && intval($_POST['remember']) == '1') ? true: false));


Brilliant! That worked like a charm! What is that method called, so I can look it up?

clunk.werclick
09-22-2009, 05:09 PM
Something with a 'Ternary' operator???

samuurai
09-22-2009, 05:16 PM
Ternary.. thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum