Comments in PHP
Comments are those human-readable texts that we should add to make our code more understandable for other programmes. It is ignored by PHP and doesn’t affect your code.
Comment are of Two types.
i. One or Single-line Comment.
ii. Multi-line Comment.
i. One or Single-line Comment:- Single line Comment is used to comment one line at a time or used in one line.
There are two types of Single line Comment:-
- Starts with //
Ex- //this is home section. - Starts with #
Ex- # this is footer section.
ii. Multi-line Comment:- It is used to comment more than one line at a time or used in more than one line. It starts with /* and ends with */.
Ex – /* this is
a multi-line
Comment*/
String Interpolation
String Interpolation is a feature or a quick shortcut which allows popping the value of a variable into a double-quoted string.
Ex – {Without String Interpolation}
{With String Interpolation}
Constant Variable
It is a type of variable which can’t be modified. To create a constant variable define() function is used.
Syntax :- define(“constant_variable”,value,case-insensitive);
Ex – define(“pi”,3.1415,True); {Note:- If case-insensitive is not assigned then, its by default FALSE}
Rules of Constant Varible :-
- No need to start the constant varible with the $ sign.
- Name only starts with a letter and an underscore(_).
- Variable name can’t start with a number.
- Constants are automatically global and can be used in the entire script.
Arithmetic/Math Operators
Sample Program
Output
Maths Functions
There are predefined mathematical Functions available in PHP to do the mathematics calculations. See the below list:-
Assignment Operators
This operator is used to assign value to the variables. For Ex –
$price=39.12 , $ram=$shyam=10 , $name=sushant
In the above example, Assignment operator (=) is used to assign the value (36.58) to the variable ($price).
Combined Assignment Operator
Sample Program
Output
To know more about Assignment Operator Click here – Assignment Operators
Click Here For Next Part – What are If, Nested if, if else and, Nested if else Statement in PHP?
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021