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.
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
Note: For our purposes here, a letter is a-z, A-Z, and the ASCII characters from 127 through 255 (0x7f-0xff).
Tip: You may also want to take a look at the Appendix S.
For information on variable related functions, see the Variable Functions Reference.
<?php |
In PHP 3, variables are always assigned by value. That is to say, when you assign an expression to a variable, the entire value of the original expression is copied into the destination variable. This means, for instance, that after assigning one variable's value to another, changing one of those variables will have no effect on the other. For more information on this kind of assignment, see the chapter on Expressions.
As of PHP 4, PHP offers another way to assign values to variables: assign by reference. This means that the new variable simply references (in other words, "becomes an alias for" or "points to") the original variable. Changes to the new variable affect the original, and vice versa.
To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which is being assigned (the source variable). For instance, the following code snippet outputs 'My name is Bob' twice:
<?php |
One important thing to note is that only named variables may be assigned by reference.
<?php |
It is not necessary to initialize variables in PHP however it is a very good practice. Uninitialized variables have a default value of their type - FALSE, zero, empty string or an empty array.
Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.
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.