summaryrefslogtreecommitdiffstats
path: root/oo/blank_object.php
blob: 751402e87b10777769b005d8586cfec091bbc409 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

/* stdClass is the default PHP object. stdClass has no properties, methods or parent.
 * It does not support magic methods, and implements no interfaces.
 * When you cast a scalar or array as Object, you get an instance of stdClass. Bare bones data structure for key-val entries
 */

$obj_w_scalar = (object) 'bar';
print $obj_w_scalar->scalar . PHP_EOL;
foreach ($obj_w_scalar as $key => $val)
    print "'$key' <--> '$val'" . PHP_EOL;

$obj = new StdClass();
$obj->foo = 'bar';