图像标签不能在php html中工作,如果我在该图像中写另一个变量工作。请在下面找到附带的代码

问题描述 投票:2回答:3
$message .= "
    <html>
        <head>
        <title>Copy of your form submission</title>
        </head>
        <body>
            <table>
                <tr>
                    <td>
                     "<img src="images/assets/thank_you.png" alt="Thank You" />"
                    </td>                
                </tr>
            </table>
        </div>
    </html>
";

如果我写

$ message。=上面的相同图片链接;

它正在工作。但是当我将图像标签写入上面的html时,那就不行了。任何人都可以帮忙吗?

php html5 frontend visual-web-developer
3个回答
3
投票

不要在"标签周围使用引号img。也可以在双引号'中使用单引号"。如下所示:

$message .= "
    <html>
        <head>
        <title>Copy of your form submission</title>
        </head>
        <body>
            <table>
                <tr>
                    <td>
                     <img src='images/assets/thank_you.png' alt = 'Thank You' />
                    </td>                
                </tr>
            </table>
        </div>
    </html>";

1
投票

你可以试试

$message .= "
  <html>
    <head>
    <title>Copy of your form submission</title>
    </head>
    <body>
        <table>
            <tr>
                <td>
                 <img src='images/assets/thank_you.png' alt='Thank You'/>
                </td>                
            </tr>
        </table>
      </div>
   </html>
";

当使用图像链接与PHP

$message .= "
<html>
<head>
<title>Copy of your form submission</title>
</head>
<body>
    <table>
        <tr>
            <td>
             <img src=".$imagelink." alt='Thank You'/>
            </td>                
        </tr>
    </table>
  </div>
 </html>
";

1
投票

我从你的代码中理解的是字符串中的concat可能有3种可能的方法来纠正它

第一:

$message .= "
    <html>
        <head>
        <title>Copy of your form submission</title>
        </head>
        <body>
            <table>
                <tr>
                    <td>
                     <img src='images/assets/thank_you.png' alt='Thank You' />
                    </td>                
                </tr>
            </table>
        </div>
    </html>
";

第二:

$message .= "
    <html>
        <head>
        <title>Copy of your form submission</title>
        </head>
        <body>
            <table>
                <tr>
                    <td>";
                     $message .='<img src="images/assets/thank_you.png" alt="Thank You" />';
                    $message .="</td>                
                </tr>
            </table>
        </div>
    </html>
";

第三:

$message .= "
        <html>
            <head>
            <title>Copy of your form submission</title>
            </head>
            <body>
                <table>
                    <tr>
                        <td>
                         <img src=\"images/assets/thank_you.png\" alt=\"Thank You\" />
                        </td>                
                    </tr>
                </table>
            </div>
        </html>
    ";
© www.soinside.com 2019 - 2024. All rights reserved.