小弟我可以用一个类类型去另一个类中声明跟定义变量吗

WBOY
Release: 2016-06-13 12:20:42
Original
898 people have browsed it

我可以用一个类类型去另一个类中声明跟定义变量吗?
我自己试了一下,不行啊,要怎么弄?
------解决思路----------------------
楼主说的是这样吗
class aa{
public $name;
}

class bb{
function testaa(aa $a){
$a->age=333;
}
}

$aa=new aa();
$bb=new bb();

$bb->testaa($aa);

echo $aa->age;

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!