编辑php以便插入HTML?
我有一些php,我想在上面插入html,上面写着//do stuff编辑php以便插入HTML?,php,Php,我有一些php,我想在上面插入html,上面写着//do stuff <?php $cat = 8; //8 is changed to be the category you need if (in_category($cat)){ //do stuff } ?> 理想情况下,我希望它是这样的。但不确定在哪里关闭和重新打开php标记 <?php $cat = 8; //8 is changed to be the category you
<?php $cat = 8; //8 is changed to be the category you need
if (in_category($cat)){
//do stuff
}
?>
理想情况下,我希望它是这样的。但不确定在哪里关闭和重新打开php标记
<?php $cat = 8; //8 is changed to be the category you need
if (in_category($cat)){
<div id="testing">Im some test content here</div>
}
?>
我这里有一些测试内容
如果in_类别($cat)
返回TRUE
我这里有一些测试内容
div#如果在_类别($cat)
中返回TRUE
实现这一点的最简单方法是使用phpecho
函数。更多关于函数的信息
<?php $cat = 8; // 8 is changed to be the category you need
if (in_category($cat)) {
echo "<div id='testing'>I am some test content.</div>"
} // if
?>
实现这一点的最简单方法是使用phpecho
函数。更多关于函数的信息
<?php $cat = 8; // 8 is changed to be the category you need
if (in_category($cat)) {
echo "<div id='testing'>I am some test content.</div>"
} // if
?>
如果您认为您的文档默认为HTML,则开始和结束PHP块。因此,您可以按如下所示将块拆分为两个php块,并且它仍将保持其程序登录
<?php
$cat = 8; //8 is changed to be the category you need
if (in_category($cat)){
?>
<div id="testing">Im some test content here</div>
<?php
}
?>
我这里有一些测试内容
这在风格上有点尴尬,但PHP就是这样 如果您认为您的文档默认为HTML,则开始和结束PHP块。因此,您可以按如下所示将块拆分为两个php块,并且它仍将保持其程序登录
<?php
$cat = 8; //8 is changed to be the category you need
if (in_category($cat)){
?>
<div id="testing">Im some test content here</div>
<?php
}
?>
我这里有一些测试内容
这在风格上有点尴尬,但PHP就是这样 你可以用两种不同的方式来做
(一)
这里有一些html
(二)
你可以用两种不同的方法来做
(一)
这里有一些html
(二)
您不必关闭和打开php标记,您可以使用echo
。只需确保使用\
<?php
$cat = 8;
if (in_category($cat)){
echo "<div id=\"testing\">Im some test content here</div>";
}
?>
否则,您可以关闭/重新打开php标记,如下所示:
<?php
// php
?>
<!-- HTML -->
<?php
// more php
?>
然而,回显的好处是可以很容易地插入一些php变量的值
<?php
$name = "John";
echo "<b>$name</b>";
?>
您不必关闭和打开php标记,您可以使用echo
。只需确保使用\
<?php
$cat = 8;
if (in_category($cat)){
echo "<div id=\"testing\">Im some test content here</div>";
}
?>
否则,您可以关闭/重新打开php标记,如下所示:
<?php
// php
?>
<!-- HTML -->
<?php
// more php
?>
然而,回显的好处是可以很容易地插入一些php变量的值
<?php
$name = "John";
echo "<b>$name</b>";
?>
最好不要假设短php标记(是的,你是对的。也许我们有不同的php.ini
设置。让我编辑它。最好不要假设短php标记(是的,你是对的。也许我们有不同的php.ini
设置。让我编辑它。