Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

What are Comments, Constant Variable, String Interpolation, Arithmetic and Assignment Operators in PHP?

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:-

  1. Starts with //
    Ex- //this is home section.
  2. 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 :-

  1. No need to start the constant varible with the $ sign.
  2. Name only starts with a letter and an underscore(_).
  3. Variable name can’t start with a number.
  4. 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?

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

What is CodeIgniter and use cases of CodeIgniter?

What is CodeIgniter? CodeIgniter is an open-source PHP web application framework designed to simplify and accelerate web development. It follows the Model-View-Controller (MVC) architectural pattern and provides…

Read More

What is PHP and use cases of PHP?

What is PHP? Are you wondering what PHP is and how it works? Look no further! In this article, we will explore the ins and outs of…

Read More

Complete guide on PHP certification courses, tutorials & training

What is PHP Hypertext Preprocessor is known as PHP. Many developers use PHP, an open-source server-side programming language, to create websites. In addition, it is a general-purpose…

Read More

Complete PHP with Laravel Certification Guide & tutorials

What is PHP with Laravel? PHP was visioned eventually in the fall of 1994 by Rasmus Lerdorf. PHP means Hypertext Preprocessor. It’s a extensively- used, open source…

Read More

Top 50 PHP Interview Questions and Answers

1) What is PHP? PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development….

Read More

Complete guide of PHP certification courses, tutorials & training

PHP is a great beginner programming language for anyone who is wanting to cross over into the coding world. Though easy to learn, it is an extremely…

Read More