gpt4 book ai didi

PHP "with"关键字 - "with"有什么作用?

转载 作者:行者123 更新时间:2023-12-05 09:18:24 28 4
gpt4 key购买 nike

有人可以解释一下 PHP“with”的作用吗?

示例开始:

假设我有一个类:

\App\fa_batch

这句话有什么区别:

$w = (with (new \App\fa_batch))
// uses 'with'
// returns App\fa_batch

还有这个声明?

$n = (new \App\fa_batch)
// does not use 'with'
// also returns App\fa_batch

上下文/背景信息:

我找不到关于with 的文档,可能是因为 PHP.net、stack overflow 和 google 搜索引擎认为 php "with"keyword 是一个常见的搜索短语。

如果上下文有帮助,我从这个答案中发现了 with 这个词的用法: https://stackoverflow.com/a/33222754/5722034

最佳答案

with 不是关键字,它是 功能。 with( 之间的额外空格是一个红色鲱鱼。

5.2 docs include it in miscellaneous helpers . The source is available on github as well

关于PHP "with"关键字 - "with"有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44636142/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com