如何修复此html以能够分配给php变量?

如何修复此html以能够分配给php变量?,php,html,class,Php,Html,Class,我有30行长的HTML代码。我不想把这一切都改成 我创建了一个名为page and save in.inc file的php类 我必须将这些HTML代码分配给$home->content。我可以复制并粘贴我的html代码吗 这是页面显示的方式: public function Display() { echo "<html>\n<head>\n"; $this -> DisplayTitle(); $this -> DisplayKey

我有30行长的HTML代码。我不想把这一切都改成 我创建了一个名为page and save in.inc file的php类

我必须将这些HTML代码分配给$home->content。我可以复制并粘贴我的html代码吗

这是页面显示的方式:

public function Display()
{
    echo "<html>\n<head>\n";
    $this -> DisplayTitle();
    $this -> DisplayKeywords();
    echo "</head>\n<body>\n";
    echo "<div class = \"container\">\n";
    $this -> DisplayHeader();
    echo $this -> content;
    $this -> DisplayFooter();
    echo "</div>\n</body>\n</html>\n";
}
公共功能显示()
{
回显“\n\n”;
$this->DisplayTitle();
$this->DisplayKeywords();
回显“\n\n”;
回音“\n”;
$this->DisplayHeader();
echo$this->content;
$this->DisplayFooter();
回显“\n\n\n”;
}
提前感谢您

如果您的HTML代码中包含“全部”,那么您可以在echo语句的开头和结尾使用单引号,您无需更改任何内容

public function Display()
{
    echo '<html>\n<head>\n';
    $this -> DisplayTitle();
    $this -> DisplayKeywords();
    echo '</head>\n<body>\n';
    echo '<div class = "container">\n';
    $this -> DisplayHeader();
    echo $this -> content;
    $this -> DisplayFooter();
    echo '</div>\n</body>\n</html>\n';
}
公共功能显示()
{
回显'\n\n';
$this->DisplayTitle();
$this->DisplayKeywords();
回显'\n\n';
回音'\n';
$this->DisplayHeader();
echo$this->content;
$this->DisplayFooter();
回显'\n\n\n';
}

虽然乌斯曼的答案似乎解决了您的问题,但了解PHP中不同类型引号之间的一些差异可能会很有用。单引号和双引号之间的差异之一是双引号将计算字符串,并且您放入其中的任何变量都将有其值放在你的绳子上

例如:

$myNum = 2;
echo 'I have $myNum apples.'; //will output: I have $myNum apples.
echo "I have $myNum apples."; //will output: I have 2 apples.

这显然是对差异的一个非常基本的解释。

我已经尝试过$home->content=?>“html代码”太棒了!!非常感谢rar。由于这个基本的解释,我现在可以做更多!!