![]() |
What are the keywords of PHP developers? |
How To Use Constants| and Keywords List | with Examples in PHP
Constants in PHP: An element of a program whose value can not be changed at the time of execution of the script is called constant.PHP constant starts with a letter or underscore. PHP constant does not start with a dollar sign($). No space is allowed in the constant name. Constants are global in nature. define() function is used to create constant in PHP.
Function defines in PHP
1. It is a predefined function of PHP.
2. It is used to set a variable with a value that can be used anywhere in the program like a global variable.
3.It has three-parameter variable name,variable value,case-sensitivity.
4. Its value can not be modified means we can say that it assigns a constant value to the variable.
Some Others Languages Keywords
👉C++ Language Keywords
👉Java Language Keywords
👉Python Language Keywords
Syntax in PHP
define(constant_name,constant_value,case_sensitivity); |
constant_name: It is the name of the constant.
constant_value: It is the value of the constant.
case_sensitivity: Case-sensitivity part of define function is optional. By default, the variable name is case sensitive but if we put the true value at the place of case sensitivity then it becomes insensitive.
Case sensitive constant: In this example the constant name (NAME) is case sensitive.
<?php define("Name;", "Icoderweb"); echo NAME; *****OUPUT***** Name:Icoderweb ?> |
Case insensitive
constant: Just put true in place of case-sensitive
parameter to make constant insensitive.
<?php define("NAME", "Icodrweb",true); echo NAME."<br>"; echo Name."<br>"; echo name."<br>"; *****OUPUT***** Icoderweb Icoderweb Icoderweb ?> |
Sum of Two Number in PHP?
<?php define('FIRST',10); define('SECOND',20); define('SUM',FIRST+SECOND); echo "Sum Of two numbers:".SUM; *****OUPUT***** Sum Of two numbers:30 ?> |
We can also assign the constant value to a variable.
<?php define('FIRST',100); define('SECOND',100); $sum=FIRST+SECOND; echo "Sum Of two numbers:".$sum; *****OUPUT***** Sum Of two numbers:200 ?> |
Keywords in PHP: The word which is pre-defined in the library is called keyword. Its
functionality is also pre-defined.
Keywords can not be used as a variable, function
name, class name, or as an identifier. Examples of keywords are abstract, break, const, continue, function, etc.
Some important keywords List in PHP
Abstract And array() as break case catch class clone cons continue declare default die() do echo else else if empty() if include switch for while public private protected static try catch throw etc |