Skip to content Skip to sidebar Skip to footer

Php Echo Other Php Code

Im trying to have php code that contains an echo. within that echo however, I need it to echo php code within it. a short example is bellow.

Solution 1:

In a html context, <?php, <something, etc, is the opening of a html tag. Edit < with his html entity &lt; to prevent it happening..

&lt;?php

Even better, use htmlspecialchars:

<?php echo htmlspecialchars('<?php echo "test"; ?>'); ?>

Solution 2:

Otherwise, try reversing it:

while ($row = mysql_fetch_array($result)) 
{
    ?>
    <div style="position: relative;" >
        <img src="Backgrounds/<?=$row[id]?>.jpg" alt="error">
        <br /><br />
        <?php
            //Some php content that also uses $row[] content
        ?>
        <br />
    </div>
    <?php
}

And also switch to PDO objects.


Post a Comment for "Php Echo Other Php Code"