Home >> PHP - MySQL PHP with example codes - 1.2 [Page 8] Article by: Shelton Manage Friday, 22nd May, 2009
About Constants
Constants is a specific data type in PHP wich, unlike variables. In fact, you cannot change the value of constant once it has bean set.
To create a constant, you use the define() function instead of the assignment operator (=) used for variables. define ('NAME', 'value');
Notice that, as a rule of thamb, constants are named using all capitals, although this is not required. Most importantly, constants do not use the initial dollar sign as variables do (because technically constants are not variables).
Printing constants requries one of tow techniques; echo 'Hello, ' .NAME; or echo 'Hello, ' ,NAME;
You cannot print constants using echo "Hello, NAME" because not the value of the NAME constant.
Ex: constants.phps | constants.php
Page: First - 1 2 3 4 5 6 7 8 9 10 - Last
|
|