[在html文件中使用javascript时,我可以在全局范围内分配var mythis=this
。 PHP中有类似的方法吗?
<html><head>
<script> var mythis= this;</script>
</head><body></body></html>
这在php中也是可能的吗?
<?php
$mythis = ....????
// or in a function or class?
function a() { $t = ....????; }
?>
$ this在PHP中是一个伪变量,当在对象的上下文中调用方法时,该引用是对调用对象的引用。例如:
<?php
class A{
private $a = 1;
public function getA(){
return $this->a;
}
}?>