php中==和===有什么区别?我不确定何时使用两者.
更新的注释:因此它显示在StackOverflow搜索中,==和===之间的差异与!=和!==之间的差异相同.
我注意到你确实可以continue
在switch语句中使用关键字,但是在PHP上它并没有达到我的预期.
如果它失败了PHP,谁知道它失败了多少其他语言呢?如果我在语言之间切换很多,如果代码的行为不像我期望的那样,那么这可能是一个问题.
我应该避免continue
在switch语句中使用吗?
PHP(5.2.17)失败:
for($p = 0; $p < 8; $p++){
switch($p){
case 5:
print"($p)";
continue;
print"*"; // just for testing...
break;
case 6:
print"($p)";
continue;
print"*";
break;
}
print"$p\r\n";
}
/*
Output:
0
1
2
3
4
(5)5
(6)6
7
*/
Run Code Online (Sandbox Code Playgroud)
C++似乎按预期工作(跳转到for循环结束):
for(int p = 0; p < 8; p++){
switch(p){
case 5:
cout << "(" << p << ")";
continue;
cout << "*"; // just for testing...
break;
case 6:
cout << "(" << …
Run Code Online (Sandbox Code Playgroud) 虽然,这是一个最好的启动开发语言; 但我不知道为什么PHP在命名功能等方面缺乏一致性?我已经开发多年了,但是我经常错过拼写函数名称并忘记它们的参数结构.为什么PHP中没有任何标准约定用于命名?有时候,它就像substr
有时候一样str_replace
?我经常忘记needle
应该是第一个论点还是第二个?或者haystack
是第一还是第二?PHP的团队是否致力于开发一致的约定和名称?