- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我喜欢使用的 PHP 的一个功能是冒号风格的 if 语句(我不知道它实际上叫什么。)
<?php if(something):?>
<html stuff>
<?php endif;?>
但我最近尝试对多个案例执行此操作:
<?php if(something):?>
<html stuff>
<?php else if(something):?>
<html stuff>
<?php endif;?>
第三行出现错误(else if
):
Unexpected T_IF
是否可以通过这种方式制作 if-else if?
最佳答案
我能够让它工作。
在这种非常特殊的情况下,else if
不是 elseif
的同义词。
用 elseif
代替 else if
解决了这个问题。
<?php if(something):?>
<html stuff>
<?php elseif(something):?>
<html stuff>
<?php endif;?>
来自 PHP.net :
Note: Note that elseif and else if will only be considered exactly the same when using curly brackets as in the above example. When using a colon to define your if/elseif conditions, you must not separate else if into two words, or PHP will fail with a parse error.
关于php - if 和 else if 在 PHP 中,冒号样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29592979/
我正在尝试使用字符串类型的变量动态调用函数,即变量将包含字符串形式的函数名称。因此,我需要使用该变量调用函数。 所以,我正在使用 Scala Reflection。如果函数接受 Sting 数据类型,
class X extends Y { X(int a, int b) : super(a,b); } 有人可以给我解释冒号:的语法含义吗? 最佳答案 Dart 中的此功能称为“初始化列表”。 它
我正在寻找一些为旧的 jQuery 版本 v.1.6.4 编写的 jquery 代码。它有一个多属性选择器,如下所示: "span:[id^='someid-']" 选择器用于各种功能,如“查找”
This question already has answers here: How do you access the matched groups in a JavaScript regular
显然,冒号在 Java 中有多种使用方式。有人介意解释一下它的作用吗? 例如这里: String cardString = ""; for (PlayingCard c : this.list) /
我在用 c 编程,我将 c 代码编译为汇编代码,但是当我用 NASM 汇编程序重新编译代码时,它给我一个错误 操作数后预期的逗号、冒号、修饰符或行尾。这发生在 第 6 行,第 7 行和第 8 行。请帮
我正在寻找一个字符来使用文件名定界符(我将多个文件名存储在一个纯文本字符串中)。 Windows 似乎不允许 : , ? , * , , " , | , /和 \在文件名中。显然,\和 /不能使用,
我有一个变量 $entry 设置为: stdClass Object ( [im:name] => stdClass Object ( [label] => Amazing Breaker ) etc
这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the h
本文实例讲述了Python数据类型中的“冒号“[::]——分片与步长操作。分享给大家供大家参考,具体如下: 例如有如下字符串: ?
我创建了一个将 Excel 文件转换为 Access 数据库的应用程序。在转换过程中,MACAddress 列数据中的“:”符号需要替换为空格。 我尝试使用 replace 方法修改查询,但它不起作用
我在 ruby 中将散列转换为 yaml,但它添加了 : 到键:例如: :name: "Name" :value: "Value" 如果有办法避免并输出: name: "Name" value:
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicate: VB Using colons to put two statements on same line 我在 Exce
我的 createSQLQuery() 方法使用具有 : 字符的表 Tables::IMS_EPISODE, 这将被视为a Paramater ,需要设置 有没有办法转义这个字符,这样它就不会被视为参
我收到了一个定义游戏“棋盘”对象的 Python 类,以及一些在构造函数中初始化的成员。大部分内容都很简单,但我不理解此代码段最后两行中集合初始化中“:”运算符的含义: class Board: BL
在我的元素中,有一个库生成元素的情况,我需要从那里选择特定的元素——恰好包含一个带有“:”的属性。 换句话说,我最终尝试选择使用:document.querySelectorAll("[xml:spa
这个问题在这里已经有了答案: Is there any difference between the `:key => "value"` and `key: "value"` hash notati
这个问题在这里已经有了答案: What does C++ struct syntax "a : b" mean (5 个回答) 关闭8年前。 struct _USBCHECK_FLAGS {
我在分配变量时不小心使用了 : 而不是 = ,令我惊讶的是它没有产生错误。例如,以下运行没有投诉: Python 3.7.4 (default, Jul 9 2019, 18:15:00) [Cla
我对定义/调用 Lua 函数时使用的冒号表示法感到非常困惑。 我以为我已经明白了,直到我看到这段代码: function string.PatternSafe( str ) return (
我是一名优秀的程序员,十分优秀!