Brian Breeden
Brian Breeden

Reputation: 101

Quotes/Double Quotes within PHP/MySql

This is the piece of code I am currently working with:

$outputDisplay .= '<div class="col-md-3">
                      <p class="launch">Mission: '.$mission.'</p>';

//If there are mission details, they will be displayed here
if (!$details){
    $outputDisplay .= "";
}
else{
    $outputDisplay .= '<a href="'.$details.'"target="_blank">Mission Details</a>';
}
//Closes out mission/details section
$outputDisplay .= '</div>';

I am building a row and here is what I am trying to accomplish. It will display data from $mission regardless, there will always be information there. However, there are not always websites that are associated with missions, represented by $details. $details is a website address or nothing at all.

In short, if there is information there, I want it to be represented as a link. I think I am getting backwards with the various quotes and double quotes. Any help would be great for a beginner like me.

Upvotes: 0

Views: 37

Answers (1)

Marc B
Marc B

Reputation: 360572

Just use a HEREDOC, which eliminates having to worry about quotes at the PHP level:

if ($details) {
    $outputDisplay .= <<<EOL
<a href="{$outputDisplay}" target="_blank">Mission Details</a>
EOL;
}

Upvotes: 5

Related Questions