How should I understand this line?

Please, could you explain this line for me:

if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])

FYI these two line also appear in the script:

<input name="activate" type="submit" id="activate" value="Betalt" />&nbsp;&nbsp;
<input name="deactivate" type="submit" id="deactivate" value="Ej betalt" /></td>
markera-betalning-ny.php
Lennart EricsonAmateurAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
This the ternary operator: it's a more concise but leass clear way to write a conditional statement.
That lines can be rewritten this way:

if(isset($_POST['activate'])
{
  $activate = $_POST["activate"];
}
else
{
    $deactivate = $_POST["deactivate"]);
}

Open in new window

Marco GasiFreelancerCommented:
The human translation is: if user clicked button called 'activate' then assign the value 'Betalt' to the variable $activate, otherwise assign the value 'Ej betalt' to the variable $deactivate.
Chris Harte2015 Top Expert (Most Article Points)Commented:
That is a ternary expression
http://php.net/manual/en/language.operators.comparison.php

if $_POST['activate'] is set then set $activate to its value, otherwise set $deactivate to $_POST['deactivate']

using spaces makes it more readable
if(isset($_POST['activate']) ? $activate = $_POST["activate"] : $deactivate = $_POST["deactivate"])

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Randy DownsOWNERCommented:
Maybe this will help.

The POST Method

The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.

Lennart EricsonAmateurAuthor Commented:
Thanks guys! I appreciate you made it readible for a human!
Regards,
lericson
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.