If $myVariable is already set

I like to make the following.

(1) If $myVariable is already set, The value of $myVariable is the value which is already set.
(2) If $myVariable is not yet set, The value of $myVariable is “myVar”
(3) Print the value of $myVariable.

I wrote the code below for it.

<?php 
if (isset($myVariable) )
{$myVariable==$myVariable}
else {$myVariable="myVar"};
echo $myVar
?>

The temperal URL http://dot.kr/x-test/if.php which has the code above causes Parse error: syntax error, unexpected ‘}’ in …\if.php on line 3 .
Is the code above right on the track?
How can I fix the Parse error?

try

 
<?php 
 
if (!isset($myVariable)) {
    $myVariable="myVar";
}
 
echo $myVar;
 
?>
 

that’s ok :slight_smile:

and good catch picking up the error I missed.

 <?php 
 
if (!isset($myVariable)) {
    $myVariable="myVar";
} 
echo $myVar[COLOR="Red"]iable[/COLOR];
?> 

Thank you, your code is short and works fine.