Nowdoc question

This code works fine but as soon as I add a NOWDOC and try to echo it, it will not be parsed at all. All the code will be echoed without parsing.

 <?php
if( $detect->isMobile() && !$detect->isTablet() ){
echo <<<'EOD'


EOD;

}
 else
$now =<<<'EOD'



						  <div class="tab-9 st_view"><div class="st_view_inner">


						  People who viewed {$agentsStuff['bizName']} also viewed:<br><br>


    
                             	

<table class="table table-striped table-responsive table-hover table-condensed">
 

$counter=0;
$result1 = mysql_query("SELECT bizID,bizName,bizAddr,bizCity,bizZip,bizPhone,bizState,lname,fname,category FROM final5 WHERE bizZip = '$bizZip' AND bizState='$bizState' AND bizCity='$bizCity'
GROUP by bizName  HAVING bizID != '$bizID' LIMIT 12");  
 while($r=mysql_fetch_assoc($result1))
{

$bizID =  {$r['bizID']};
$bizName =  {$r['bizName']};
$bizAddr =  {$r['bizAddr']};
$bizCity =  {$r['bizCity']};
$bizZip =  {$r['bizZip']};
$bizPhone =  {$r['bizPhone']};
$bizState =  {$r['bizState']};
$lname =  {$r['lname']};
$fname =  {$r['fname']};
$category =  {$r['category']};

	$bizCityLink = str_replace(" ","-",$bizCity);
	$bizCityLink = strtolower($bizCityLink);
	$bizStateLink = strtolower($bizState);
	$bizNamev = replaceForLink($bizName);

	$defaultString = 'Construction';
			if(replaceForText($fname)=="")
			{
               $bizNameLink = replaceForText($bizName);
	           if(empty($bizNameLink))  $bizNameLink = $defaultString;
}
else
{
               $bizNameLink = replaceForText($fname." ".$lname);
}

  if($counter==0)
                  {
                                      echo "<tr>";
										 }
echo '<td><a href="'. $urlPrefix . $bizStateLink . '/' . $bizCityLink . '/' . $bizNamev . '-' . $bizID . '.html">' . $bizName . '</a><br>

	 '.( (replaceForText($bizName) == $bizNameLink) ? "":replaceForText($fname." ".$lname)." ").' 
'.$category.'

<br>

			</td>';
 if($counter==3)
                  {
                        echo "</tr>";
                        $counter = 0;
                        continue;
                  }
                                  $counter++;
            }

            ?>

		
</table>

EOD;
?>

Open in new window

seoptiAsked:
Who is Participating?
 
Ray PaseurCommented:
See if this helps clarify what PHP is doing with your code.
http://iconoun.com/demo/temp_seopti.php

<?php // demo/temp_seopti.php

/**
 * See https://php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
 * See http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28652540.html
 */
error_reporting(E_ALL);

// PREPARE TWO DOCUMENTS
$doc1 = <<<'EOD'
THIS IS HERE BECAUSE $X == 3
EOD;

$doc2 = <<<'EOF'
NO MATTER WHAT YOU PUT HERE IT WILL BE ECHOED INTACT
IT WILL NOT BE INTERPRETED AS PHP CODE!
EOF;


// SET A CONDITION AND TRY THE CONDITIONAL ECHO
$x = 3;

if( $x == 3 )
{
    echo $doc1;
} else {
    echo $doc2;
}


// SET A DIFFERENT CONDITION AND TRY THE CONDITIONAL ECHO
$x = 'crump';

if( $x == 3 )
{
    echo $doc1;
} else {
    echo $doc2;
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.