DebugBar Forums
 
 HOME 
 DOWNLOAD 
 BUY 
 DOC / WIKI 
 FORUM 
 CONTACT 
Stay tuned : rss feed

Forum Home


advanced search


You are not logged in.

Announcement

When reporting a problem or a bug :
* Provide your OS version (INCLUDING service pack) and installed IE version.
* Provide your IETester version
* Provide the IE Tab version opened to generate the problem
* Provide a test case with a sample url or sample code to reproduce the problem
* Provide a step by step explanation on how to reproduce the problem.
* If needed provide additional information.

Thanks.

#1 2012-01-11 21:43:23

crisangel3
New member
Registered: 2011-03-22
Posts: 1

Brazilian Website in problem

Visibility

The visibility of a property or method can be defined by prefixing the declaration with the keywords public, protected or private. Class members declared public can be accessed everywhere. Members declared protected can be accessed only within the class itself and by inherited and parent classes. Members declared as private may only be accessed by the class that defines the member.
Property Visibility

Class properties must be defined as public, private, or protected. If declared using var, the property will be defined as public.
<?php
/**
* Define MyClass
*/
class MyClass
{
    public $public = 'Public';
    protected $protected = 'Protected';
    private $private = 'Private';

    function printHello()
    {
        echo $this->public;
        echo $this->protected;
        echo $this->private;
    }
}

$obj = new MyClass();
echo $obj->public; // Works
echo $obj->protected; // Fatal Error
echo $obj->private; // Fatal Error
$obj->printHello(); // Shows Public, Protected and Private


/**
* Define MyClass2
*/
class MyClass2 extends MyClass
{
    // We can redeclare the public and protected method, but not private
    protected $protected = 'Protected2';

    function printHello()
    {
        echo $this->public;
        echo $this->protected;
        echo $this->private;
    }
}

$obj2 = new MyClass2();
echo $obj2->public; // Works
echo $obj2->private; // Undefined
echo $obj2->protected; // Fatal Error
$obj2->printHello(); // Shows Public, Protected2, Undefined

?>

Offline

 

Partners : Debugbar | Mobilier de bureau | Debugbar Wiki | IEForge | Lampes design | La fourmi créative