List Info

Thread: note 60635 deleted from function.property-exists by nlopess




note 60635 deleted from function.property-exists by nlopess
user name
2006-02-28 23:38:48
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

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )