Help breaking down a this php code

Hi All,

I having been getting some help with a custom store that I am building and have been given a piece of code by support that works but I do not understand how and would be grateful if someone could break it down for me.


I understand the isset. So for me this statement says if session "currencySymbol" exists, but I do not know what the ? is for at the end as well as the :"$"
Who is Participating?
bigeven2002Connect With a Mentor Commented:

The ? : style is a ternary operator which is meant to be shorthand for traditional if statements.

The code above is the same as:
    $_SESSION['currencySymbol'] = "$";

Open in new window

So basically, if that SESSION variable is not set, then set it to "$".
Dave BaldwinFixer of ProblemsCommented:
What he said.  See Ternary Operator on this page:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.