最佳答案 if (!empty-6ren">
gpt4 book ai didi

PHP - 如果变量不为空,则回显一些 html 代码

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

如果变量不为空,我想显示一些 html 代码,否则我什么都不显示。

我试过这段代码但不起作用:

<?php 
$web = the_field('website');
if (isset($web)) {
?>
<span class="field-label">Website: </span><a href="http://<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a>
<?php
} else {
echo "Niente";
}
?>

最佳答案

if (!empty($web)) {
?>
<span class="field-label">Website: </span><a href="http://<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a>
<?php
} else { echo "Niente";}

http://us.php.net/manual/en/function.empty.php

关于PHP - 如果变量不为空,则回显一些 html 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9592855/

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