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.
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
The name of a constant follows the same rules as any label in PHP. A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thusly: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
Tip: You may also want to take a look at the Appendix S.
Note: For our purposes here, a letter is a-z, A-Z, and the ASCII characters from 127 through 255 (0x7f-0xff).
Like superglobals, the scope of a constant is global. You can access constants anywhere in your script without regard to scope. For more information on scope, read the manual section on variable scope.
You can define a constant by using the define()-function. Once a constant is defined, it can never be changed or undefined.
Only scalar data (boolean, integer, float and string) can be contained in constants. Do not define resource constants.
You can get the value of a constant by simply specifying its name. Unlike with variables, you should not prepend a constant with a $. You can also use the function constant() to read a constant's value if you wish to obtain the constant's name dynamically. Use get_defined_constants() to get a list of all defined constants.
Note: Constants and (global) variables are in a different namespace. This implies that for example TRUE and
$TRUEare generally different.
If you use an undefined constant, PHP assumes that you mean the name of the constant itself, just as if you called it as a string (CONSTANT vs "CONSTANT"). An error of level E_NOTICE will be issued when this happens. See also the manual entry on why $foo[bar] is wrong (unless you first define() bar as a constant). If you simply want to check if a constant is set, use the defined() function.
These are the differences between constants and variables:
Constants do not have a dollar sign ($) before them;
Constants may only be defined using the define() function, not by simple assignment;
Constants may be defined and accessed anywhere without regard to variable scoping rules;
Constants may not be redefined or undefined once they have been set; and
Constants may only evaluate to scalar values.
See also Class Constants.
Another Useful functions:
zend.copy-constructor | zend-api.zval-update-constant | zend-api.zend-update-class-constants | zend-api.zend-u-register-constant | zend-api.zend-u-get-constant | zend-api.zend-register-stringl-constant | zend-api.zend-register-string-constant | zend-api.zend-register-long-constant | zend-api.zend-register-double-constant | zend-api.zend-register-constant | zend-api.zend-get-constant | zend-api.zend-declare-class-constant | zend-api.zend-declare-class-constant-stringl | zend-api.zend-declare-class-constant-string | zend-api.zend-declare-class-constant-long | zend-api.zend-declare-class-constant-double | zend-api.zend-declare-class-constant-bool | zend-api.register-stringl-constant | zend-api.register-string-constant | zend-api.register-main-stringl-constant | zend-api.register-main-string-constant | zend-api.register-main-long-constant | zend-api.register-main-double-constant | zend-api.register-long-constant | zend-api.register-double-constant | streams.constants | reserved.constants | migration52.global-constants | migration52.class-constants | language.oop5.constants | language.oop.constructor | language.constants.predefined | language.constants | internals.pdo.constants | http.constants | function.xsl-xsltprocessor-construct | function.tidy-construct | function.swish-construct | function.swfvideostream.construct | function.swftextfield.construct | function.swftext.construct | function.swfsprite.construct | function.swfsound.construct | function.swfshape.construct | function.swfprebuiltclip.construct | function.swfmovie.construct | function.swfmorph.construct | function.swfgradient.construct | function.swffont.construct | function.swfbutton.construct | function.swfbitmap.construct | function.swfaction.construct | function.soap-soapvar-construct | function.soap-soapserver-construct | function.soap-soapparam-construct | function.soap-soapheader-construct | function.soap-soapfault-construct | function.soap-soapclient-construct | function.simplexml-element-construct | function.sdo-model-reflectiondataobject-construct | function.sdo-das-relational-construct | function.sammessage-constructor | function.samconnection-constructor | function.runkit-constant-remove | function.runkit-constant-redefine | function.runkit-constant-add | function.pharfileinfo-construct | function.phar-construct | function.pdo-construct | function.ming-useconstants | function.httprequestpool-construct | function.httprequest-construct | function.httpquerystring-construct | function.httpmessage-construct | function.httpinflatestream-construct | function.httpdeflatestream-construct | function.harudoc-construct | function.get-defined-constants | function.dom-domxpath-construct | function.dom-domtext-construct | function.dom-domprocessinginstruction-construct | function.dom-domimplementation-construct | function.dom-domentityreference-construct | function.dom-domelement-construct | function.dom-domdocument-construct | function.dom-domcomment-construct | function.dom-domattr-construct | function.directoryiterator-construct | function.constant | function.bcompiler-write-constant | function.arrayobject-construct | function.apc-load-constants | function.apc-define-constants | curl.constants |
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.