将经典的asp if语句转换为php

时间:2014-04-15 00:47:37

标签: php asp-classic

我还是非常新的PHP并且需要将现有页面转换为php,有人能告诉我如何将下面的代码转换为php吗?

<%If rsMembership.Fields.Item("MemberOfGroup").Value = "0" then response.write ("Main Member")Else response.write ("Belongs to Member = ")&(rsMembership.Fields.Item("MemberOfGroup").Value)End if%>

更新:这有效,不确定它是否正确,似乎无法将值设为=“0”,只有当我把&lt;“1”

时才有效
    <?php
if ($row_rsMembership['MemberOfGroup']< "1")
   {
   echo "Main Member";
   }
else
   {
   echo "Belongs to Member =" . $row_rsMembership['MemberOfGroup'];
   }
?>

1 个答案:

答案 0 :(得分:1)

要比较PHP If语句中的值,请使用==而不是=,即:

if ($row_rsMembership['MemberOfGroup'] == "0")
   {
   echo "Main Member";
   }
else
   {
   echo "Belongs to Member =" . $row_rsMembership['MemberOfGroup'];
   }