Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts

    Some help with syntax

    Hi,

    I've got a function which has is set up like this:
    Code:
    function login($username, $password, $remember = false)
    I want to somehow call this function like this (in pseudo code):
    Code:
    login($username,$password,if($_POST['remember']) evaluate to "true")
    Can this be done?

    Thanks!

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    login($username,$password, ((isset($_POST['remember']) && intval($_POST['remember']) == '1') ? true : false));
    Last edited by MattF; 09-22-2009 at 06:24 PM. Reason: Missing space. Aesthetic.

  • Users who have thanked MattF for this post:

    samuurai (09-22-2009)

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MattF View Post
    Code:
    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?

  • #4
    New Coder
    Join Date
    Jul 2009
    Posts
    91
    Thanks
    5
    Thanked 6 Times in 6 Posts
    Something with a 'Ternary' operator???

  • Users who have thanked clunk.werclick for this post:

    samuurai (09-22-2009)

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Posts
    144
    Thanks
    64
    Thanked 0 Times in 0 Posts
    Ternary.. thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •