Reputation: 9848
I'm really new to php and am having trouble debugging the following snippet.
<?php
$hintMaintain = <<< EOT
<hr />
<div id="user_hint"> ABC DE <span class="status_strtolower($account['status_value'])">ucfirst($account['status_value'])</span>FGH</div>
<div style="margin: 0px 74px 0px 74px; text-align: center; height: 66px; width:66px; background: url('img/strtolower($maintain)hint.png') no-repeat;">
<span style="line-height: 66px; font-size: 36px; color: black;">$countdown</span>
</div>
EOT;
eval("\$hintMaintain = \"$hintMaintain\";");
?>
<!-- SOME HTML -->
<?php echo $hintMaintain; ?>
This shows a server error. I haven't been able to work this out.
Help? Thanks.
Upvotes: 3
Views: 125
Reputation: 961
<hr />
<div id="user_hint"> ABC DE
<span class="status_strtolower(<? =$account['status_value']); ?>">
<? =ucfirst($account['status_value']);?>
</span>FGH</div>
<div style="margin: 0px 74px 0px 74px; text-align: center; height: 66px; width:66px; background: url('img/<?=strtolower($maintain);?>hint.png') no-repeat;">
<span style="line-height: 66px; font-size: 36px; color: black;"><?=$countdown/></span>
</div>
<? =$something; ?>
^^^ will output this something.
Upvotes: 2
Reputation: 1283
Try:
<?php
$hintMaintain = '<hr />
<div id="user_hint">
<p> ABC DE
<span class="status_'.strtolower($account['status_value']).'">'.ucfirst($account['status_value']).'</span>
FGH</p>
</div>
<div style="margin: 0px 74px 0px 74px; text-align: center; height: 66px; width:66px; background: url(\'img/'.strtolower($maintain).'hint.png\') no-repeat;">
<span style="line-height: 66px; font-size: 36px; color: black;">'.$countdown.'</span>
</div>';
?>
<!-- SOME HTML -->
<?php echo $hintMaintain; ?>
Upvotes: 3
Reputation: 3209
What are you trying to do?
You are trying to execute HTML as PHP
Look at the phpdocs on eval http://php.net/manual/en/function.eval.php
The first argument must be valid PHP statements.
I think you are trying to cache the content and display it after, look at this: http://php.net/manual/en/function.ob-flush.php
Upvotes: 1