Get the App
SLTechnology News&Howtos  ›  Development  › 

Where is the memory location of static static properties and methods in php object-oriented

Shulou Source: shulou.com Published: 2022-06-03 19:33:59 10月24日 Update

Editor to share with you where the php object-oriented static static properties and methods of memory location, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

The details are as follows:

The memory location of the static static property-- > class, not the object. Let's do a test to prove it.

As can be seen from the output:

1. Echo Human:$name: when the class is declared, the static attribute exists and does not depend on the object. Therefore, there is only one static property (meaning in memory, the location is not in the object; if in the object, then instantiating an object, there is a corresponding static location, such as the height property)

2. Print_r ($p1): the printed result has only height attribute, but no name.

3. After the value of the static property changes, the value of the property of all objects will be affected.

Methods, whether static or normal, exist in the class memory space. The proof is also very simple, new an object, print_r (object).

These are all the contents of the article "where is the memory location of static static properties and methods in php object-oriented". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Objects properties static location memory methods articles content only results ordinary not much most instances meaning more knowledge space industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information NVidia Redmi OPPO Reno