PHP: Variable variables - Manual in Deutsh
PHP: Variable variables - Manual in French
PHP: Variable variables - Manual in Polish

You Are At PHP: Variable variables - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevChapter 12. VariablesNext

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:

<?php
$a
= 'hello';
?>

A variable variable takes the value of a variable and treats that as the name of a variable. In the above example, hello, can be used as the name of a variable by using two dollar signs. i.e.

<?php
$$a = 'world';
?>

At this point two variables have been defined and stored in the PHP symbol tree: $a with contents "hello" and $hello with contents "world". Therefore, this statement:

<?php
echo "$a ${$a}";
?>

produces the exact same output as:

<?php
echo "$a $hello";
?>

i.e. they both produce: hello world.

In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if you write $$a[1] then the parser needs to know if you meant to use $a[1] as a variable, or if you wanted $$a as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second.

Warning

Please note that variable variables cannot be used with PHP's Superglobal arrays within functions or class methods.

klimatyzacje lg warszawa
uroda
Koszulki Smoke Story Koszulki Smoke Story
Electro lista serwisów
Na budowie Opel Corsa mur niszczy mur z cegieł Ciągnie i przewrac

Another Useful functions:


zend.variables | zend-api.zend-u-delete-global-variable | zend-api.zend-print-variable | zend-api.zend-get-compiled-variable-value | zend-api.zend-get-compiled-variable-name | zend-api.zend-delete-global-variable | security.variables | reserved.variables | migration4.variables | language.variables.variable | language.variables.scope | language.variables.predefined | language.variables | language.variables.external | functions.variable-functions | function.variant-xor | function.variant-sub | function.variant-set | function.variant-set-type | function.variant-round | function.variant-pow | function.variant-or | function.variant-not | function.variant-neg | function.variant-mul | function.variant-mod | function.variant-int | function.variant-imp | function.variant-idiv | function.variant-get-type | function.variant-fix | function.variant-eqv | function.variant-div | function.variant-date-to-timestamp | function.variant-date-from-timestamp | function.variant-cmp | function.variant-cat | function.variant-cast | function.variant-and | function.variant-add | function.variant-abs | function.stats-variance | function.stats-covariance | function.mb-convert-variables | function.import-request-variables | function.define-syslog-variables | class.variant |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.