Home > Backend Development > PHP Tutorial > 新手,关于类内部变量的引用。

新手,关于类内部变量的引用。

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-20 12:55:46
Original
964 people have browsed it

class ABC{public $Apublic $Cpublic function B($C){ //这里变量$C可以像我想象的那样当作形参来传值吗?echo $A;//这里对变量$A的引用可以吗?还是必须写成这样echo $this->A;echo $C;}}
Copy after login





我本来可以一个个的自己试的,但是如果你们直接告诉我,会省去我不少时间的。
谢谢,我又在偷懒,我不努力,我什么都得不到。


回复讨论(解决方案)


我已经自己试完了,看来我就不适合当个新手。
送给你们分,好不好。

class ABC{	public $A;	public $C;	public function test($C){//$C 是你传进来的参数		echo $this->A;//在类中定义的要用$this->		echo $C;	}}
Copy after login


谢谢,我还会再来提问的。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template