gpt4 book ai didi

PHP 回显一大块文本

转载 作者:IT王子 更新时间:2023-10-29 00:53:51 25 4
gpt4 key购买 nike

我是 PHP 的新手,我不知道使用 echo 函数的规则是什么。例如,如果我需要回显一大块 css/js,我是否需要将回显添加到每一行文本,或者是否有一种方法可以通过单个回显来回显一大块代码?

当我尝试回显像这样的一大块代码时,出现错误:

if (is_single()) {
echo '<link type="text/css" rel="stylesheet" href="http://jotform.com/css/styles/form.css"/><style type="text/css">
.form-label{
width:150px !important;
}
.form-label-left{
width:150px !important;
}
.form-line{
padding:10px;
}
.form-label-right{
width:150px !important;
}
body, html{
margin:0;
padding:0;
background:false;
}

.form-all{
margin:0px auto;
padding-top:20px;
width:650px !important;
color:Black;
font-family:Verdana;
font-size:12px;
}
</style>

<link href="http://jotform.com/css/calendarview.css" rel="stylesheet" type="text/css" />
<script src="http://jotform.com/js/prototype.js" type="text/javascript"></script>
<script src="http://jotform.com/js/protoplus.js" type="text/javascript"></script>
<script src="http://jotform.com/js/protoplus-ui.js" type="text/javascript"></script>
<script src="http://jotform.com/js/jotform.js?v3" type="text/javascript"></script>
<script src="http://jotform.com/js/location.js" type="text/javascript"></script>
<script src="http://jotform.com/js/calendarview.js" type="text/javascript"></script>
<script type="text/javascript">

JotForm.init(function(){
$('input_6').hint('ex: myname@example.com');
});
</script>';
}else {

}

有没有更好的方法来回显大块代码而无需大量工作(例如,向每一行添加回显)?

最佳答案

Heredoc syntax可能非常有用:

// start the string with 3 <'s and then a word
// it doesn't have to be any particular string or length
// but it's common to make it in all caps.
echo <<< EOT
in here is your string
it has the same variable substitution rules
as a double quoted string.
when you end it, put the indicator word at the
start of the line (no spaces before it)
and put a semicolon after it
EOT;

关于PHP 回显一大块文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2672642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com