Php - Class

About

A class is the blueprint code that create an object.

Example

<?php
class Foo {

    // A variable
    public $myPublicVar = 'value';
    private $myPrivateVar = 'value';

    // A constant   
    const CONSTANT = 'constant value';
   
    function showVariable() {
        print 'Print a variable '.$this->myPublicVar;
    }

    function showConstant() {
        echo  self::CONSTANT . "\n";
    }
    
    public static function aStaticMethod() {
        // ...
    }
} 

Operator

instanceof

$a instanceof $b

Documentation / Reference


Powered by ComboStrap