note 108852 modified in language.oop5.visibility by danbrown

From: Date: Wed, 30 May 2012 14:45:40 +0000
Subject: note 108852 modified in language.oop5.visibility by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188297@lists.php.net to get a copy of this message
<?php
class test {
	public $public = 'Public var';
	protected $protected = 'protected var';
	private $private = 'Private var';
	
	public static $static_public = 'Public static var';
	protected static $static_protected = 'protected static var';
	private static $static_private = 'Private static var';
}

$class = new test;
print_r($class);
?>

The code prints
test Object ( [public] => Public var [protected:protected] => protected var [private:test:private] => Private var )

Functions like print_r(), var_dump() and var_export() prints public, protected and private variables, but not the static variables. --was-- class test { public $public = 'Public var'; protected $protected = 'protected var'; private $private = 'Private var'; public static $static_public = 'Public static var'; protected static $static_protected = 'protected static var'; private static $static_private = 'Private static var'; } $class = new test; print_r($class); The code prints test Object ( [public] => Public var [protected:protected] => protected var [private:test:private] => Private var ) Functions like print_r(), var_dump() and var_export() prints public, protected and private variables, but not the static variables. http://php.net/manual/en/language.oop5.visibility.php

« previous php.notes (#188297) next »