Multiplication of Two Numbers in PHP

Multiplication of Two Numbers in PHP. In this program, we can print the multiplication of numbers in PHP. Variables that you define when writing a policy are known as user-defined variables. As long as the first variable begins with a letter, you can use any combination of letters and numbers as variable names: Variables that store single values, such as texts or integers, do not need to be initialized.

define('a', 4); 
for($i=1; $i<=4; $i++)
echo $i*a;







Define in PHP

A constant is defined with the define() function. Constants are similar to variables, with the following exceptions: The value of a constant cannot be modified once it has been set. A leading dollar symbol ($) is not required for constant names. Regardless of scope, constants can be accessed. 

Const defines constants at compile time, while define() declares them at run time. By supplying true as the third argument to define(), you can define case insensitive constants, whereas consts are always case sensitive.

For Loop in Php

When you know how many times you want the script to run, you use the for loop. PHP for loop can be used to traverse set of code for the specified number of times. If the number of iterations is known, it should be utilised; otherwise, a while loop should be used. When you already know how many times you want to execute a block of code, you use for loop.