#28 - ViewBag-like PHP class

Data: 2018-09-29 12:00 - PHP

Simple entity framework ViewBag-like class for PHP to store values.

<?php
class ViewBag {
    private static $bag = [];
    public static function __callStatic($name, $arguments) {
        $args_count = count($arguments);
        if ($args_count == 0)
            return @self::$bag[$name];
        else if ($args_count == 1)
            self::$bag[$name] = $arguments[0];
        else
            self::$bag[$name] = $arguments;
    }
}

Previous snippet | Next snippet