php _call and _callStatic
php __call and __callStatic
PHP5?的对象新增了一个专用方法?__call(),这个方法用来监视一个对象中的其它方法。如果你试着调用一个对象中不存在的方法,__call?方法将会被自动调用。
?
__call()?is triggered when invoking inaccessible methods in an object context. __callStatic()?is triggered when invoking inaccessible methods in a static context.
?
class?MethodTest?{
????public?function?__call($name,?$arguments)?{
????????//?Note:?value?of?$name?is?case?sensitive.
????????echo?"Calling?object?method?'$name'?"
?????????????.?implode(',?',?$arguments).?"\n";
????}
????/**??As?of?PHP?5.3.0??*/
????public?static?function?__callStatic($name,?$arguments)?{
????????//?Note:?value?of?$name?is?case?sensitive.
????????echo?"Calling?static?method?'$name'?"
?????????????.?implode(',?',?$arguments).?"\n";
????}
}
$obj?=?new?MethodTest;
$obj->runTest('in?object?context');
MethodTest::runTest('in?static?context');??//?As?of?PHP?5.3.0
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Context is the environment and status information when the program is executed. It can include a variety of information, such as the value of variables, the call stack of functions, the execution location of the program, etc., allowing the program to make corresponding decisions based on different contexts. and perform corresponding operations.

How to use context to implement request link tracking in Go. In the microservice architecture, request link tracking is a very important technology that is used to track the delivery and processing of a request between multiple microservices. In the Go language, we can use the context package to implement request link tracking. This article will introduce how to use context for request link tracking and give code examples. First, we need to understand the basic concepts and usage of the context package. The context package provides a mechanism

How to use context to implement request caching in Go Introduction: When building web applications, we often need to cache requests to improve performance. In the Go language, we can use the context package to implement the request caching function. This article will introduce how to use the context package to implement request caching, and provide code examples to help readers better understand. What is context? : In the Go language, the context package provides a way to pass between multiple goroutines

How to use context to implement request timeout control in Go Introduction: When we make network requests, we often encounter request timeout problems. A network request that does not respond for a long time will not only waste server resources, but also affect overall performance. In order to solve this problem, the Go language introduced the context package, which can be used to implement request timeout control. This article will introduce how to use the context package to implement request timeout control in Go, and attach corresponding code examples. 1. Understand the context package co

The context package in the Go language is used to pass request context information in the program. It can pass parameters, intercept requests and cancel operations between functions across multiple Goroutines. To use the context package in Go, we first need to import the "context" package. Below is an example that demonstrates how to use the context package to implement request parameter passing. packagemainimport("context"

How to use context to implement request retry strategy in Go Introduction: When building a distributed system, network requests will inevitably encounter some failures. In order to ensure the reliability and stability of the system, we usually use a retry strategy to handle these failed requests to increase the success rate of the request. In the Go language, we can use the context package to implement the request retry strategy. This article will introduce how to use the context package in Go to implement a request retry strategy, with code examples. 1. What is

How to use context to implement request encapsulation and decapsulation in Go. In the development of Go language, we often encounter situations where we need to encapsulate and decapsulate some request parameters. This situation is especially common in complex systems, where we need to pass request parameters to different functions and modules, and there may be nested calls between these functions and modules. In order to facilitate the management and delivery of these request parameters, we can use the context package in Go to implement request encapsulation and decapsulation. The context package is the Go language

The common application of context concepts in Java include "Servlet context", "Android context" and "Spring context": 1. In Java Web development, ServletContext refers to the context environment of the entire Web application; 2. In Android development , Context is a core Android system class; 3. In the Spring framework, ApplicationContext represents the Spring container context.
