PHP Refresher 1

Types

PHP supports ten primitive types: bool, int, floatstring, array, object, callable, iterable, resource, and NULL.

class ManyTypes {
    private $isObject = true; // bool
    private $myAge = 10; // int
    private $nationalDebt = 20000000000000.25; // float
    public $languages = [
        'php',
        'JavaScript',
    ];

    public function getMyAge()
    {
        echo "I am $this->myAge years old";
    }
}
$manyTypes = new ManyTypes; // object
$manyTypes->getAge(); // function
$languages = $manyTypes->languages; // array

Variables

$languages = $manyTypes->languages;

Constants

define("FOO",     "something");

const CONSTANT = 'Hello World';