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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.