PHP内部回声 [英] PHP echo inside echo

查看:85
本文介绍了PHP内部回声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法调用数据库中的HTML/PHP内容:

I'm trying to call an HTML/PHP content that it's inside my database using:

<?php echo $row_content['conteudo']; ?>

当该行被调用时,HTML正确显示,但PHP未正确显示. 我相信这是主回波内部回波的原因.

When the row is called the HTML appears correctly but the PHP doesn't. I belieave it's cause of the echo inside the main echo.

<?php echo "
<h3>Hello</h3>
<?php do { ?>
  <div class=\"indios\">
    <a href=\"indio.php?id=<?php echo $row_indiosct['id']; ?>\">
      <img src=\"galeria/indios/<?php echo $row_indiosct['foto']; ?>\" alt=\"<?php echo $row_indiosct['nome']; ?>\" />
      <br /><?php echo $row_indiosct['nome']; ?></a></div>
  <?php } while ($row_indiosct = mysql_fetch_assoc($indiosct)); ?> "
 ?>

此代码的第一行与第一个代码字段具有相同的回显,这里不再重复,它只是在寻求帮助并了解问题出在哪里.

The line one of this code is the same echo as the first code field, it's not repeating, it's there just for help and to understand where is the problem.

我已经修复了一些引号,但是它在第一回波的行中给出了错误.

I already fixed some quotation marks but it gives an error in the line of the 1st echo.

推荐答案

那是我见过的最丑陋的代码...

That is some of the ugliest code I have ever seen...

<?php 
echo '
<h3>Hello</h3>';

while ($row_indiosct = mysql_fetch_assoc($indiosct))
{
  echo '
    <div class="indios">
      <a href="indio.php?id='.$row_indiosct['id'].'">
        <img src="galeria/indios/'. $row_indiosct['foto'].'" alt="'.$row_indiosct['nome'].'" />
      <br />'.$row_indiosct['nome'].'</a>
    </div>';
} 
?>

您还可以使用 HEREDOC 语法.

这篇关于PHP内部回声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆