Dan*_*ife 6 php with-statement
我想知道是否有类似于javascript或VB的with声明,但在PHP中
其工作方式,例如在VB中如下所示.这两个代码片段具有相同的效果:
array[index].attr1 = val1;
array[index].attr2 = val2;
array[index].attr3 = val3;
Run Code Online (Sandbox Code Playgroud)
等于:
With(array[index])
.attr1 = val1
.attr2 = val2
.attr3 = val3
End With
Run Code Online (Sandbox Code Playgroud)
不完全是with语句,但您可以在示例中使用引用:
$r = &$array[index];
$r->attr1 = val1;
$r->attr2 = val2;
$r->attr3 = val3;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2492 次 |
| 最近记录: |