Classes and Objects

suggest change

Versions

[{“Name”:“4.0”,“GroupName”:“PHP 4.x”},{“Name”:“4.1”,“GroupName”:“PHP 4.x”},{“Name”:“4.2”,“GroupName”:“PHP 4.x”},{“Name”:“4.3”,“GroupName”:“PHP 4.x”},{“Name”:“5.0”,“GroupName”:“PHP 5.x”},{“Name”:“4.4”,“GroupName”:“PHP 4.x”},{“Name”:“5.1”,“GroupName”:“PHP 5.x”},{“Name”:“5.2”,“GroupName”:“PHP 5.x”},{“Name”:“5.3”,“GroupName”:“PHP 5.x”},{“Name”:“5.4”,“GroupName”:“PHP 5.x”},{“Name”:“5.5”,“GroupName”:“PHP 5.x”},{“Name”:“5.6”,“GroupName”:“PHP 5.x”},{“Name”:“7.0”,“GroupName”:“PHP 7.x”},{“Name”:“7.1”,“GroupName”:“PHP 7.x”}]

Introduction

Classes and Objects are used to to make your code more efficient and less repetitive by grouping similar tasks.

A class is used to define the actions and data structure used to build objects. The objects are then built using this predefined structure.

Syntax

Remarks

Classes and Interface components

Classes may have properties, constants and methods.

class Foo {
    private $foo = 'foo'; // OK
    private $baz = array(); // OK
    private $bar = new Bar(); // Error!
}

Interfaces cannot have properties, but may have constants and methods.

interface FooBar {
    const FOO_VALUE = 'bla';
    public function doAnything();
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Classes and objects:
* Classes and Objects

Table Of Contents
2 Arrays
4 Types
10 Cookies
11 Classes and objects
14 JSON
15 SOAP
17 cURL
19 XML
21 Traits
35 UTF-8
36 URLs
38 PHPDoc
41 Loops
44 Closur
72 YAML
77 Cache
78 Streams
81 PDO
82 SQLite3
83 Sockets
87 MongoDB
93 IMAP
94 Redis
95 Imagick
102 APCu
108 PSR