MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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

PHP arithmetic operators table: + addition, - subtraction, * multiplication, / division, % modulus with examples

Sample Program

Output

Browser output of myfile.php showing arithmetic results 6, 2, 8, 2 and 1

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

Diagram labeling $price = 36.58 as variable, assignment operator and value

In the above example, Assignment operator (=) is used to assign the value (36.58) to the variable ($price).

Combined Assignment Operator

PHP combined assignment operators table: +=, -=, *=, /=, %= with equivalents and results for m=15

Sample Program

PHP code setting $m=10 then echo $m+=15 to demonstrate combined assignment

Output

Browser output of myfile.php showing 25 from the combined assignment example

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

PHP Code for Godaddy VPS Server SMTP Email Relay

This page shows how to send email from a GoDaddy VPS through GoDaddy's SMTP relay on port 25 with plain PHP sockets and no extra libraries. Below…

Read More

Laravel: oauth_access_tokens clean up process

using Laravel Passport—the oauth_access_tokens table balloons when tokens aren’t expiring, not being revoked on logout, or not being purged. Here’s a practical, safe cleanup + prevention plan…

Read More

Laravel: Complete Guide of Laravel Passport

Here’s a comprehensive, up-to-date step-by-step tutorial for setting up and using Laravel Passport (OAuth2 API authentication) with clear explanations, working code samples, and troubleshooting tips—suitable for local…

Read More

Laravel: What is APP_KEY in Laravel?

Let’s break down both what APP_KEY is in a Laravel .env file, why it matters, and its use cases. I’ll also explain how it’s generated and what…

Read More

XAMPP – LAMPP Tutorials: List of Production Files to Cleanup Guide

Here’s a comprehensive and updated tutorial on which files should be cleaned up regularly in a production environment running XAMPP (under /opt/lampp), what each file/folder is, and…

Read More

artisan Tutorials: php artisan passport

When you run php artisan passport:install, Laravel attempts to do the following: Running php artisan passport:install is a crucial setup step when using Laravel Passport for API…

Read More