Skip to content

Instantly share code, notes, and snippets.

@devmsh
devmsh / MagicUser.php
Last active September 6, 2016 10:44
PHP Magical Setter and Getter
<?php
// once you add the magical setter and getter
// you can can access any private fields as usual
// but you can also develop custom setter and getter if you want
$user = new MagicUser();
$user->username = "test";
$user->password = "pass";
echo $user->username; // will print Test not test.