php中的with语句
我想知道是否有类似于 javascript 或 VB 的 with
语句,但在 php 中
它的工作方式,例如在 VB 中如下所示。这两个代码片段具有相同的效果:
array[index].attr1 = val1;
array[index].attr2 = val2;
array[index].attr3 = val3;
等于:
With(array[index])
.attr1 = val1
.attr2 = val2
.attr3 = val3
End With
I am wondering if there is something similar to javascript or VB's with
statement but in php
The way this works, for example in VB is shown below. The two code snippets do the same effect:
array[index].attr1 = val1;
array[index].attr2 = val2;
array[index].attr3 = val3;
is equal to :
With(array[index])
.attr1 = val1
.attr2 = val2
.attr3 = val3
End With
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不完全是 with 语句,但您可以在示例中使用引用:
Not exactly the with statement, but you can use references in your example:
如果需要像示例中那样使用数组,您可以使用 array_merge 函数来模拟
with 语句
:输出:
If needed with arrays as in your example, you can mimic the
with statement
by using the array_merge function:Output: