gpt4 book ai didi

php - 为什么这样做? (php 点符号)

转载 作者:可可西里 更新时间:2023-10-31 23:03:15 25 4
gpt4 key购买 nike

我在长时间使用 ruby​​ 后写了一些 php 代码,我不小心写了这个:

[root@ip-10-160-47-98 test]# cat run.php
<?php

class MyTest {

public function run() {
var_dump(this.test);
}
}

$object = new MyTest();
$object->run();
[root@ip-10-160-47-98 test]# php run.php
string(8) "thistest"
[root@ip-10-160-47-98 test]#

现在,this.test 应该是 $this->test,但编译器实际上很乐意让它运行。

有谁知道 (this.test) 是如何转换成字符串“thistest”的?

在 php 5.3.2 amazon 实例 ami-e32273a6 (CentOS 5.4) 上编译运行

-丹尼尔

最佳答案

thistest被隐式转换为字符串,.是连接操作符。

关于php - 为什么这样做? (php 点符号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2901820/

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