PHP if / then语句

时间:2018-03-07 19:33:19

标签: php if-statement

需要帮助一些PHP修改WP插件,这是付费会员专业版。在这里可怕的PHP。

我要做的是创建一行代码,如果成员资格级别等于XXX,则打印此链接。所以我想要的变量就在我想象的这一行的某个地方:

<li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:
</strong> <?php echo $current_user->membership_level->name?></li>

以上只是我想要创建此if / then链接语句的页面中已找到的一段代码。

如下所示:

<?php if($Membership Level == $Conflicts of Interest #14124(that's the name 
of one level) then print this link.

AM我有道理吗?

编辑:

感谢下面的一些帮助,这似乎有效:

<?php if($membership_level == 'Conflicts of Interest #14124') {
echo "<a href=\"conflicts-of-interest-in-modern-legal-practice-and-internal-
investigations-14124/\">Testing</a>";
}
?>

但&#39;利益冲突#14124&#39;即使它是正确的名称也不匹配。

1 个答案:

答案 0 :(得分:0)

然后在html页面中使用if else语句

<?php if($membership_level == 'string to be compared') {
    echo 'the link that you want to print if it is a string. you can replace this string 
          with a variable if the value is in variable'
} else {
   'any other text if require else you can remove the else block'
}
?>

希望有所帮助。

相关问题