I have just been introduced to the heredoc method and am getting into it slowly.
I figured I could use conditional statements inside the heredoc syntax but Im running into some roadblocks - (mainly my lack of knowledge)
What Im trying to do is create a hr from an array - I can get the color and the style but when it comes to showing the result, I'm falling short.
If I run this by itself it works fine - it uses a checkbox called dashed_dashed_use and if its checked it runs this, and all is well - however. Im trying to use a ifelse statement inside to simply show a
if the checkbox is not "checked".
// START HEREDOC OUTPUT STRING
$output = <<< START
START;
// IF Yes Box HAS CONTENT - ADD TO OUTPUT
// ELSE IGNORE
if (!empty($dashed_dashed_use)) {
$output .= <<< DD1
<hr style="border: 2px dashed; color:{$dashed_dashed};" data-dashed_dashed="{$dashed_dashed}">
DD1;
}
// ADD CLOSING TAGS TO OUTPUT
$output .= <<< OUTPUT_FINAL
OUTPUT_FINAL;
return $output;
}
I cant just have a hr after the START as it will always show. So I need it so that it's a regular hr unless DD1 has been activated by the checkbox - (there are more varieties of the same, but I figured I would be able to replicate a single working version and just change the names of the $ fields.
Is this pretty straightforward, or do I need to code copies for every instance of hr I have.
Aucun commentaire:
Enregistrer un commentaire