const php code example

Example 1: php déclarer une constante URL

<?php
  define("CONSTANT", "Bonjour le monde.");
  echo CONSTANT; // affiche "Bonjour le monde."
?>

Example 2: php const

<?php
    define('CONSTANT', 'Hello world !');
    const CONSTANT = 'Hello world !';
    const NEW_CONSTANT = CONSTANT.' And beyond...';
    const ANIMALS = array('dog', 'cat', 'ant');
    define('ANIMALS', array('dog', 'cat', 'ant'));
?>

Example 3: construtor php

class BaseClass {
    function __construct() {
        print "In BaseClass constructor\n";
    }
}

class SubClass extends BaseClass {
    function __construct() {
        parent::__construct();
        print "In SubClass constructor\n";
    }
}

Tags:

Php Example