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

image tag not working in php html, if i write another variable in that image working. please find the attached code below

$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 .= 上面 link 相同的图片 ;

它正在工作。但是当我像上面那样将图像标签写入 html 时,就无法正常工作了。谁能帮忙?

不需要在 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>";

你可以试试

$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>
";

并且在将图像 link 与 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>
";

我从你的代码中了解到字符串中的连接有问题,可能有 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>
    ";