Init Class properties method. PHP code example open

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 +
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

Leave a Reply

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

How many?: 22 + 22

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