Home > Backend Development > PHP Problem > How to call method in php without instantiation

How to call method in php without instantiation

藏色散人
Release: 2023-03-01 20:26:01
Original
3353 people have browsed it

PHP can use static calls or PHP reflection to call methods without instantiation. That is to say, when class members are defined as private, they can also be accessed externally, that is, the class can be accessed without creating an instance of the class. members and methods.

How to call method in php without instantiation

PHP does not instantiate the calling method

Static calling, using PHP reflection.

Related introduction:

PHP reflection mechanism

Introduction

Even if a class member is defined as private, it can be accessed externally without creating an instance of the class. Can access class members and methods.

PHP has added a reflection mechanism since version 5.0. It provides a set of powerful reflection APIs, allowing you to access and use classes, methods, properties, parameters, annotations, etc. in the PHP running environment. Its functions It is very powerful and is often used in highly extensible PHP frameworks to automatically load plug-ins, automatically generate documents, and can even be used to extend the PHP language. Since it is a built-in oop extension of PHP and a feature of the language itself, it can be used without adding additional extensions or configurations.

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to call method in php without instantiation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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