LonghornPHP 2026

Voting

: min(one, three)?
(Example: nine)

The Note You're Voting On

Jay Cain
16 years ago
Regarding the initialization of complex static variables in a class, you can emulate a static constructor by creating a static function named something like init() and calling it immediately after the class definition.

<?php
class Example {
    private static $a = "Hello";
    private static $b;

    public static function init() {
        self::$b = self::$a . " World!";
    }
}
Example::init();
?>

<< Back to user notes page

To Top