[ create a new paste ] login | about

Link: http://codepad.org/RD6F8WWE    [ raw code | output | fork ]

PHP, pasted on Jun 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

$obj = new StdClass;

$obj->prop = 'my default public property';  // Public by default, so
echo $obj->prop;                            // this will work


// Class with a private property 
class NotStdClass {
    private $prop = 'This is private';
}

$privateObj = new NotStdClass;
echo $privateObj->prop;        // This is private, so fatal error


Output:
1
2
my default public property
Fatal error: Cannot access private property NotStdClass::$prop on line 15


Create a new paste based on this one


Comments: