Ben çiftleşmiş ile karıştırmasını yaşıyorum ve ben tarayıcıya html içeren bir şablon yankı gerekir ve bir durum içine çalıştırmak php. Nasıl PHP değerlendirmek ve tarayıcıya gönderebilirim?
Yani burada bir örnek (main.php) bulunuyor:
<div id = "container">
<div id="head">
<?php if ($id > 10): ?>
<H3>Greater than 10!</H3>
<?php else: ?>
<H3>Less than 10!</H3>
<?php endif ?>
</div>
</div>
Ve sonra template.php in:
<?php
$contents; // Contains main.php in string format
echo eval($contents); // Doesn't work... How do I do this line??
?>
EDIT: My template also allows you to inject data from the controller Smarty-style. Would an output buffer allow me to do this and then evaluate my php. The ideal is that it does a first-pass through the code and evaluates all the tags in first, then runs the php. This way I can create loops and stuff from using data sent from my controller.
So maybe a more complete example:
<div id = "container">
<div id = "title">{$title}</div> <!-- This adds data sent from a controller -->
<div id="head">
<?php if ($id > 10): ?>
<H3>Greater than 10!</H3>
<?php else: ?>
<H3>Less than 10!</H3>
<?php endif ?>
</div>
</div>
Teşekkürler!