Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of object-oriented problems in PHP5

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

In this issue, the editor will bring you an example analysis of PHP5 object-oriented problems. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

You may be familiar with PHP5 object-oriented, although the response to some problems has been enhanced a lot, but there are still many things that are much weaker than java's object-oriented. Some things are even confusing, such as the following PHP5 object-oriented code, b extends a, where the constructor of a when instantiating b is not executed? Do not know when instantiating b, PHP in the end is how to implement, the master to help solve the doubt! And the static member of PHP should be able to use it in non-static methods, but it turns out to be an error.

All right, post the code first.

Class a {function _ construct () {echo "a";}} class b extends a {function _ construct () {echo "b";} private $xylene 100; public static function getx () {return $this- > x }} $x=new b (); echo $x-> getx ()

The result is:

B100

"a" has no output. I really don't know the order of class initialization in PHP5 object-oriented.

The above is the example analysis of PHP5 object-oriented problems shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report