Jump to content
shaffiq_fiq88

Syntax function

Recommended Posts

Hello.I'm new to PHP, a beginner. I downloaded a text editor and the only server scripting use by the text editor is PHP. I want to rewrite the script to ASP server scripting. However, I found a syntax that I don't understand. I'd tried searching in google and W3Schools.com but didn't find its function.

$_GET['dir'] = $_POST['dir'] ? $_POST['dir'] : $_GET['dir'];

What is the function of that syntax?

Share this post


Link to post
Share on other sites

it's a statement using a ternary operator, which in simple cases can replace an if/else statement.http://php.net/manual/en/language.operators.phpi.e.

if($_POST['dir']){  $_GET['dir'] = $_POST['dir'];}else{  $_GET['dir'] = $_GET['dir'];};

Share this post


Link to post
Share on other sites
it's a statement using a ternary operator, which in simple cases can replace an if/else statement.http://php.net/manual/en/language.operators.phpi.e.
if($_POST['dir']){  $_GET['dir'] = $_POST['dir'];}else{  $_GET['dir'] = $_GET['dir'];};

Thanks. Now, I understand it. Thanks so much. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...