Category PHP

If Statement in PHP

PHP if statement

The if statement is one of the most straightforward conditional statement in PHP. It is the simplest decision-making construct that allows you to control the flow of a program by specifying an alternative path of execution. This statement executes a…

Control Statements in PHP

Types of control statements in PHP

In this tutorial, you will learn about control statements in PHP. A simple PHP program is a set of statements that generally contain expressions and end with a semicolon. When you execute a simple PHP program, the PHP interpreter executes…

Operator Precedence in PHP

In this tutorial, we’ll learn about the operator precedence and associativity in PHP with important examples. In PHP, expressions are in general evaluated from left to right. However, when an expression contains more than one operator, operator precedence determines the…

Bitwise Operators in PHP

The bitwise operators are those operators in PHP which allow you to perform operations on the binary representations of integers. Each integer value is represented by a sequence of bits (0s and 1s). We commonly use bitwise operators to perform…

Ternary Operator in PHP

An example of PHP ternary operator or conditional operator.

The ternary operator in PHP provides a one-line approach to representing a simple conditional statement. We commonly use it as a shorthand method for if-else statement which makes the code much more simple, concise and readable. The ternary operator allows…