note 60635 deleted from function.property-exists by nlopess
| From: | nlopess@php.net | Date: | Tue, 28 Feb 2006 23:38:48 +0000 |
| Subject: | note 60635 deleted from function.property-exists by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104588@lists.php.net to get a copy of this message | ||
Note Submitter: friss at shize dot de
----
property_exists behaves differently if used inside a class or outside regarding the visibility of
properties:
<?php
class Foo
{
public $pbl = 'public';
protected $prt = 'protected';
private $prv = 'private';
function __construct()
{
var_dump(property_exists($this , 'pbl'));
var_dump(property_exists($this , 'prt'));
var_dump(property_exists($this , 'prv'));
}
}
$f = new Foo();
echo '<br />';
var_dump(property_exists($f , 'pbl'));
var_dump(property_exists($f , 'prt'));
var_dump(property_exists($f , 'prv'));
?>
output:
bool(true) bool(true) bool(true)
bool(true) bool(false) bool(false)
so public, protected and private properties are property_exists == true from inside.
from outside only public properties are property_exists == true
hth, kai