Can I use one class type to declare and define variables in another class?

Source: Internet
Author: User
Can I use one class type to declare and define variables in another class? I tried it myself. no, what should I do?


Reply to discussion (solution)

Is that what the landlord said?
Class aa {
Public $ name;
}

Class bb {
Function testaa (aa $ ){
$ A-> age = 333;
}
}

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

$ Bb-> testaa ($ aa );

Echo $ aa-> age;


Although the code is simple, it is a bit complicated to pass this value. I have no mental preparation at all.


What does "aa $ a" mean? I am a newbie. I have never seen this syntax. where do I look at this?

You can paste your code to see it.
What do people's code mean?


Oh, the factory model. I just saw it before .....


I have extends inherited that class, and it is easy to work.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.