Skip to content
Advertisement

How to insert link within PHP Variable?

I have a PHP file setup as follows:

if ($preference == "Vegetarian"){
   $meal = "Vegetarian"
   $gluten_free_option = "(Click here to change order to gluten-free)";
}

echo "
   <h3>Meal Choice: $meal $gluten_free_option</h3>
"

And am attempting to generate an output of:

Meal Choice: Vegetarian (Click here to change order to gluten-free)

where the parentheses text will link to a Gluten-Free menu page. Is it possible to insert an href link within the variable $gluten_free_option?

Advertisement

Answer

Yes

$gluten_free_option = "<a href='URL HERE'>(Click here to change order to gluten-free)</a>";
Advertisement