簡體   English   中英

PHP if/then 語句

[英]PHP if/then 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.

我說得通嗎?

編輯:

感謝下面的一些幫助,這似乎有效:

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

但是“利益沖突#14124”不匹配,即使它是正確的名稱。

然后在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'
}
?>

希望有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM