Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
变量在html(php)中不起作用_Php_Html_Variables - Fatal编程技术网

变量在html(php)中不起作用

变量在html(php)中不起作用,php,html,variables,Php,Html,Variables,在这段代码中,我试图让我的变量显示在它发送的电子邮件中,因为某些原因,它不是 是否有某种方式在html中显示变量?不知道我做错了什么 不显示的变量是$ApplicatableDocument // Start email send notification <titleNew submission by $agentclient</title> </head> &l

在这段代码中,我试图让我的变量显示在它发送的电子邮件中,因为某些原因,它不是

是否有某种方式在html中显示变量?不知道我做错了什么

不显示的变量是$ApplicatableDocument

// Start email send notification



                <titleNew submission by $agentclient</title>
                </head>
                <body>

                <p>New submission by $agentclient</p>
                <table border=\"1\">
                <tr>
                <th>Date</th>
                <th>Property/Description</th>
                <th>Transaction Type</th>
                <th>Applicable Document</th>
                </tr>
                <tr>
                <td>$date</td>
                <td>$propertydescription</td>
                <td>$transactiontype</td>
                <td><a href=\"http:www.xxxxxx.net/xxxxxx/xxxx/\"><$applicabledocument</a></td>
                </tr>
                </table>

                </body>
                </html>
                ";

                // Always set content-type when sending HTML email
                $headers = "MIME-Version: 1.0" . "\r\n";
                $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
您需要使用PHP来回显每个变量的内容

<td><?php echo $date; ?></td>
<td><?php echo $propertydescription; ?></td>
<td><?php echo $transactiontype; ?></td>
....

等等。

只能在php标记之间使用php变量。现在,您正在使用php和html,而无需打开和关闭php标记

<html>
<div>Stuff</div>
<?php
//now I can use php 
echo $myVar; 
?>
<!-- now I'm back to html again-->
</html>
万一您不知道echo做什么,它只会获取变量的内容并将其打印到html文档中

所以

这意味着客户看到了你好朋友


假设是文件中较早的某个地方。

对于如此大的字符串,请在字符串中自由使用$variable

//assuming <?php and ?> is written somewhere else
$content = <<<EOD
<html><head>
<title>New submission by $agentclient</title>
                </head>
                <body>

                <p>New submission by $agentclient</p>
                <table border="1">
                <tr>
                <th>Date</th>
                <th>Property/Description</th>
                <th>Transaction Type</th>
                <th>Applicable Document</th>
                </tr>
                <tr>
                <td>$date</td>
                <td>$propertydescription</td>
                <td>$transactiontype</td>
                <td><a href="http:www.xxxxxx.net/xxxxxx/xxxx/"><$applicabledocument</a></td>
                </tr>
                </table>

                </body>
                </html>
                EOD;

                // Always set content-type when sending HTML email
                $headers = "MIME-Version: 1.0" . "\r\n";
                $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

PS:我不会纠正无效的HTML标记

您必须打开php解析器。。。此操作的快捷方式:


看到这些乱七八糟的代码。这里有人需要使用一个好的HTML/PHP编辑器,比如NetBeans,其中一个是有效的PHP,所以。。。我们真的帮不了你。你的标签在哪里?