I am having trouble echoing out heredoc
statements from one php file into another. I have one script which is used to retrieve API database information and then format that information into a heredoc
to echo the information into the index.php
page. The code that I have is:
while($artist_info = $artist_details_resource->fetch_assoc()){
$artist = <<<DOC
<img src="{$artist_info['image_url']}" alt="$artist_info['artist_name']" />
<p>{$artist_name}</p>
DOC;
}
And in the index.php script I start a php clause on the place I want this heredoc to print. The code for that is:
<?php
if($artist){
echo $artist;
}
?>
However this only prints the last heredoc string from the while loop, and not echoing out every heredoc through each iteration.