Jump to content

Syntax function


shaffiq_fiq88
 Share

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?

Link to comment
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'];};

Link to comment
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. :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...