Init Class properties method. PHP code example

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 +
1
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 ];
        }
    }

}
0

More

Comments (1)

Leave a Reply

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

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation