Software Programs and Projects

This Software Programs and Projects include programing tips and technology using different languages like VC++,ASP,JSP C#.Net,PHP,VB.Net,JavaScript,ASP.NET .Software Programs and Projects blog mainly support to software programmers and provide help through the mail.

Constants in PHP : using define()-function

Constant

A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script . A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.

How can declare Constant ?

You can define a constant by using the define()-function. Once a constant is defined, it can never be changed or undefined.

<?php // Valid constant names define("FOO", "something"); define("FOO2", "something else"); define("FOO_BAR", "something more"); // Invalid constant names define("2FOO", "something");
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world." ?>


Important things ..

  • Constants do not have a dollar sign ($) before them;
  • Constants may only be defined using the define() function.
  • Constants may only evaluate to scalar values (integer,float,boolean,strings).


tag:-Contants definition,How can declare constant in PHP ?,Constant Syntax in PHP