Working with Interceptors

PHP provides built-in interceptor methods that can intercept messages sent to undefined methods and properties.
Published di PHP, 16 days ago

This is also known as overloading, but as that term means something quite different in Java and C++, I think it is better to talk in terms of interception. PHP supports various built-in interceptor or “magic” methods. Like __construct(), these are invoked for you when the right conditions are met.

MethodDescription
__get($property)Invoked when an undefined property is accessed
__set($property, $value)Invoked when a value is assigned to an undefined property
__isset($property)Invoked when isset() is called on an undefined property
__unset($property)Invoked when unset() is called on an undefined property
__call($method, $arg_array)Invoked when an undefined nonstatic method is called
__callStatic($method, $arg_array)Invoked when an undefined static method is called

Dukung Saya supaya tetap menulis artikel-artikel yang baik, membayar sewa domain, dan server untuk blog ini. Caranya dengan donasi cendol via Trakteer.id.


No image

Fadly Dzil Jalal

PHP, Yii2 Framework, Laravel, Java, Java Swing, Hibernate, Javascript, Angular, React, MySQL, MongoDB


Dapatkan USD 200 untuk develop aplikasimu di DigitalOcean DigitalOcean Referral Badge