HOME | PHP Tutorial | CSS
facebook icon
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

PHP Constant

<< Previous Page
PHP String Function
Next Page >>
PHP Operator Types

Constants does not need $ in front. But, as a convention of PHP programmers, constants are written in capital letters (A-Z) for easier observation.
The value of a constant can't be changed during the script.
A constant is declared using the define() function. The define() function has two arguments:
First, the name of the constant
Second, the value of the constant
In the following example you will see how a value is assigned to a constant and how we can call a constant

Note: Unlike variables, PHP constants are automatically global across the entire script.

define(name, value, case-insensitive)

Example 1: Create a PHP constant with a case-sensitive name:
define ("GREETING", "Welcome to AgerNic.com/!");

Constant with a case-insensitive name. How to create?

PHP constant with a case-insensitive name:

Example 2:
<? Php
define("GREETING", "Welcome to AgerNic.com/!", true);
echo greeting;
Output: Welcome to AgerNic.com/!

Constants are global.

PHP Constants are automatically global and can be used throughout the PHP script.

Example 3:
define ("GREETING", "Welcome to AgerNic.com/!");
function phpTest() {echo GREETING;

<< Previous Page
PHP String Function
Next Page >>
PHP Operator Types

PHP 5 Constants - php tutorial

2249. PHP Tutorial - Multidimensional arrays
A multidimensional array is the same as in any other programming language: an array containing one or multiple other arrays. Multidimensional arrays are a very useful concept while. Althouth you will normally find and use two or three levels of multidime

3223. PHP 5 switch Statement , php tutorial
PHP 5 switch Statement php tutorial

2245. PHP Tutorial - For loop
The PHP for loop is native function that lops throw a piece of code while a given conditional expression is true. It normally executes for a given number of times.

3354. PHP For Loops
Learn about PHP for loops with this PHP tutorial.

1937. PHP Operator Types, php tutorial
PHP Operator Types php tutorial

3358. PHP Include
Learn about the PHP include function with this PHP tutorial.

Your add here
PHP ltrim() function

PHP strip_tags() function

PHP similar_text() function

PHP wordwrap() function

PHP substr() function

PHP isset() Function

PHP trim() function

PHP printf() function

PHP html_entity_decode() function

PHP explode() function

PHP rtrim() function

PHP lcfirst() function

PHP strlen() function

PHP htmlspecialchars_decode() function

PHP str_repeat() function

PHP strtoupper() function

CSS Border Style Width and Color
HTML Table
Deprecated: mysql_connect() mysql extension is deprecated and will be
PHP Array - What is an Array?
CSS rounded corners