PHP

TwitterFacebook
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 http://php.net/manual/en/index.php

PHP Manual

http://php.net/manual/en/language.oop5.static.php

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?" http://php.bigresource.com/Use-of-Complex-Curly-Bracket-Syntax-cMCPO7C5.html

PHP :: Use Of Complex (Curly Bracket) Syntax

http://php.net/manual/en/language.variables.variable.php

Variable variables

Sometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically. A normal variable is set with a statement such as: A variable variable takes the value of a variable and treats that as the name of a variable.

Use of Complex (Curly Bracket) Syntax - PHP

Ken in Melbourne Australia (ken@mira.net) wrote: : If I use the curly bracket syntax (referred to as the : complex syntax) within a string, how do I get to call a : function within it? : The php manual says that the first (or previous) : character for the curly bracket has to be a dollar sign '$'. http://ca3.php.net/types.string also says "you can include any value that is in the namespace" That doesn't sound to me like you can call a function, since the function is not a value (instead it creates a new value and returns it, and the result is not in any name space since it is not in a variable.) http://bytes.com/topic/php/answers/10924-use-complex-curly-bracket-syntax