首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >正确使用equals语法

正确使用equals语法
EN

Stack Overflow用户
提问于 2014-10-07 15:51:27
回答 2查看 23关注 0票数 0

有没有人能帮我写一下下面的代码

代码语言:javascript
运行
复制
if ($scope = '9001') $docref = $rs["9001ref"]; 
elseif ($scope = '14001') $docref = $rs["14001ref"];
elseif ($scope = '18001') $docref = $rs["18001ref"]; 
elseif ($scope = '9001,14001') $docref = $rs["914001ref"]; 
elseif ($scope = '9001,18001') $docref = $rs["918001ref"]; 
elseif ($scope = '14001,18001') $docref = $rs["1418001ref"]; 
elseif ($scope = '9001,14001,18001') $docref = $rs["91418001ref"];

我不确定我应该使用=还是==

我也不确定我应该用‘’还是“”

谁能让我知道,并提供一个简短的解释,以便我知道下一步,谢谢。

EN

Stack Overflow用户

发布于 2014-10-07 15:54:25

在监狱里一定要有==

代码语言:javascript
运行
复制
if ($scope = '9001') $docref = $rs["9001ref"]; 
elseif ($scope == '14001') $docref = $rs["14001ref"];
elseif ($scope == '18001') $docref = $rs["18001ref"]; 
elseif ($scope == '9001,14001') $docref = $rs["914001ref"]; 
elseif ($scope == '9001,18001') $docref = $rs["918001ref"]; 
elseif ($scope == '14001,18001') $docref = $rs["1418001ref"]; 
elseif ($scope == '9001,14001,18001') $docref = $rs["91418001ref"];

对于这种情况,更好的解决方案是使用switch而不是if-elseif条件。

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26231103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档