Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Chris Lam  >  Gettable  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: test drive
Class: Gettable
Make protected class properties accessible
Author: By
Last change: Removed leading underscore for the private attribute.
Date: 2010-03-03 20:46
Size: 491 bytes
 

Contents

Class file image Download
<?php

require_once 'Gettable.cls.php';

class 
MyClass extends Gettable
{
    protected 
$readonly "1";

    protected 
$_reallyPrivate1 "2";
    private 
$reallyPrivate2 "3";
}

$obj = new MyClass;

echo 
$obj->readonly;        // ok
echo $obj->_reallyPrivate1// Fatal error
echo $obj->reallyPrivate2;  // Fatal error

var_dump(isset($obj->readonly));        // true
var_dump(isset($obj->_reallyPrivate1)); // false
var_dump(isset($obj->reallyPrivate2));  // false