Php - Class

Card Puncher Data Processing


A class is the blueprint code that create an object.


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() {
        // ...



$a instanceof $b

Documentation / Reference

Discover More
Card Puncher Data Processing
Php - Method

Methods are functions inside a class. Call a static method from inside a class
Card Puncher Data Processing
What is a trait in Php ?

A trait is a collection of code that is added dynamically to your class. It helps to alleviate the limitation of class hierarchy (object inheritance) when: objects should share method that can't...

Share this page:
Follow us:
Task Runner