doushang4274 2015-01-05 06:16
浏览 70
已采纳

这个符号“<<< HTML”是什么意思?

While reading code of another programmer, I have encountered <<<H.TML symbol. My colleagues said that it is used to write html within a php file.

I tried to find more details about its usage but I didn't find much. Please anyone explain to me how it works and what does it called?

    public function SetContent($page = '') {

    $this->_header->SetPageNavigation($page) ;
    $budgetHTML = '';

    $signup1 = '';
         $GetHeader =  $this->_header->GetHeader() ;
         $GetFooter =  $this->_footer->GetFooter() ;

    $DocType = <<<HTML

<!DOCTYPE html>

<!--[if IE 8]>    <html class="no-js ie8 ie" lang="en"> <![endif]-->

<!--[if IE 9]>    <html class="no-js ie9 ie" lang="en"> <![endif]-->

<!--[if gt IE 9]><![endif]-->

HTML;
         $this->_html = sprintf("{$DocType}<html>");
        $this->_html .= sprintf("%s", $this->_head->GetHTML());
        $bg=$this->_common->getBgImage();
         $bg=json_decode($bg);

    if(!empty($bg->BGImage)&&(file_exists($GLOBALS['DocumentRoot'].'/bgImages/'.$bg->BGImage)))
    {
        $backgroundImage='background: url('.$GLOBALS['DOCUMENT_ROOT'].'/bgImages/'.$bg->BGImage.') no-repeat fixed top center;background-size: cover !important;';
    }
    else
    {
        $backgroundImage='';
    }
   $this->_html .= sprintf( '<body style="'.$backgroundImage.'" >

         <noscript>

            <h1 style="color:red; text-align:center; padding-top:100px;">This page needs JavaScript activated to work</h1>

            <style>div { display:none; }</style>

        </noscript>
<div class="loading"><img src="'.$GLOBALS['RootURL'].'images/main-loader.GIF" width="128" height="128"  ></div>
        <div id="wrapper"><div class="page-bg">%s%s%s%s<div class="clear"></div></div></div>', $GetHeader, $budgetHTML, $this->_maincontenthtml, $GetFooter);

    $this->_html .= sprintf("</body>");
}
  • 写回答

3条回答 默认 最新

  • doukan1258 2015-01-05 06:24
    关注

    What you're looking at is called heredoc.

    It's used to declare a long string literal when you don't want to use quotes. From the PHP documentation:

    $str = <<<EOD
    Example of string
    spanning multiple lines
    using heredoc syntax.
    EOD;
    

    In your case, they're using HTML for that symbol instead of EOD. It actually has nothing to do with HTML at all, but you could assign a large block of HTML to a variable if you wanted to, just like any other string literal value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀