PHP WordPress Job Preparation

PHP Magic Method

The following method names are considered magical: __construct()__destruct()__call()__callStatic()__get()__set()__isset()__unset()__sleep()__wakeup()__serialize()__unserialize()__toString()__invoke()__set_state()__clone(), and __debugInfo().

Function vs Method
FeatureFunctionMethod
DefinitionA block of reusable codeA function defined inside a class
ScopeGlobal (outside of class)Belongs to a class/object
Call stylefunctionName()$object->methodName()
Can be static?NoYes (with static)
Use this?NoYes (in non-static context)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top