HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
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.

Syntax:
define(name, value, case-insensitive)

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

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:
<?php
define ("GREETING", "Welcome to AgerNic.com/!");
function phpTest() {echo GREETING;
}
phpTest();
?>

<< 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
https://tutorialehtml.com/en/php-tutorial-multidimensional-arrays/

3223. PHP 5 switch Statement , php tutorial
PHP 5 switch Statement php tutorial
https://www.agernic.com/php-tutorial/php-switch-statement.html

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.
https://tutorialehtml.com/en/php-tutorial-for-loop/

3354. PHP For Loops
Learn about PHP for loops with this PHP tutorial.
https://www.quackit.com/php/tutorial/php_for_loops.cfm

1937. PHP Operator Types, php tutorial
PHP Operator Types php tutorial
http://www.agernic.com/php-tutorial/php-operator-types.html

3358. PHP Include
Learn about the PHP include function with this PHP tutorial.
https://www.quackit.com/php/tutorial/php_include.cfm

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
SQL BETWEEN Operator