0

我需要基于 php 的 if 循环,我可以在 Joomla 1.5 HTML 中插入 php 代码来查找作者,当我得到该变量时,我可以制作 IF 语句

例如

if ($author="a") {
echo "This is author a";
}

elseif ($author="b"){
echo "this is author b";
}

elseif ($author="c"){
echo "this is author c";
}

我不知道如何从文章中获取 $author 变量(名称)

4

1 回答 1

0

您应该在 if 语句中使用==or===而不是=

例子

if ($author == "a") {
    echo "This is author a";
} 

elseif ($author == "b") {
    echo "this is author b";
} 

elseif ($author == "c") {
    echo "this is author c";
}

或使用开关

switch ($author) {
    case "a" :
        echo "This is author a";
        break;
    case "b" :
        echo "This is author a";
        break;
    case "c" :
        echo "This is author a";
        break;
}
于 2012-04-24T17:27:23.213 回答