Programming PHP Constants, Comments and Data types in PHP

Constants, Comments and Data types in PHP

php constants comments and data types

PHP Constants

PHP constant is an identifier (a name) for simple value. As the name suggests, that value cannot be changed during the execution of the script. PHP constants are case-sensitive as variables and are kept always uppercase (it is not compulsory uppercase but conventionally).

PHP constants follow same naming rules as in variables, but are defined using define() function.

Example #1: PHP constant example

PHP Comments

PHP comments are C like comments. Anything written as comment is never read/executed as program. PHP comments are used to mention information about the code that can be understood by others.

Types of PHP comments

Single line comments: Marks only one line as comment from the point of comment symbol(‘//’ OR ‘#’)

Eaxmple #1:

Multiple line comments: Marks content as comment from start of comment to end using /* as start and */ as end of comment.

Eaxmple #1:


PHP data types means the types of data that the variable can store, that means if a variable stores integer data , its is integer data type.

PHP has total 10 data types:

Boolean: A Booleans expresses a TRUTH value i.e, either TRUE or FALSE.

Integer: an integer is any positive or negative number without a decimal (…., -2, -1, 0, 1, 2, 3, …)

Doubles: They are floating point or real numbers like 36.2654, 0.2365, 1065.02 etc.

String: String is a series of characters enclosed by single or double quotes.

Arrays: arrays can store more than one value at a time in a single variable in index

Null: NULLvalue represents a variable with no/null value. It is the only possible value of type

Object: Objects are instance of classes which can package up both other types of values and functions that are specific to the class.

One thought on “Constants, Comments and Data types in PHP

Leave a Reply