
PHP
Get flash to fully experience Pearltrees
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net s earch for in the [ edit ] Last updated: Fri, 29 Mar 2013 view this page in PHP Manual by : Mehdi Achour
PHP Manual
Static Keyword
I have yet to see an example that I can really get my chops into. So I am offering an example that I hope will satisfy most of us. class RubberBall { /* * ALLOW these properties to be inherited TO extending classes - that's * why they're not private. * * DO NOT ALLOW outside code to access with 'RubberBall::$property_name' - * that's why they're not public. * * Outside code should use: * - RubberBall::getCount() * - RubberBall::setStart() * These are the only routines outside code can use - very limited indeed. * * Inside code has unlimited access by using self::$property_name. * * All RubberBall instances will share a "single copy" of these properties - that's * why they're static. */ protected static $count = 0; protected static $start = 1; protected static $colors = array('red','yellow','blue','orange', 'green', 'white'); protected static $sizes = array(4, 6, 8, 10, 12, 16); public $name; public $color; public $size;Sponsored Links: Related Forum Messages: Use Constants With Complex (curly) Syntax? I was surprised to see that the following doesn't work as expected. define('CONST_TEST','Some string'); echo "What is the value of {CONST_TEST} going to be?"

