Jump to content

Syntax function


shaffiq_fiq88

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...