public function __construct($args) { $this->init_properties( $args ); } function init_properties( $args = false ) { $properties = get_class_vars( get_class( $this ) ); foreach ( $properties as $name => $val ) { if ( isset( $args[ $name ] ) ) { $this->$name = $args[ $name ]; } } }

Init Class properties method. PHP code example
Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
Tested: Wordress 4.0+, PHP 5.6 +