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

Difference Between echo and print in PHP

Echo vs. Print

  • PHP echo and print both are PHP Statements
  • Both are used to displaying the output in PHP.

What is echo

  • The echo is a statement i.e used to display the output. it can be used with parentheses echo or without parentheses echo.
  • echo can pass multiple strings separated as (,).
  • echo does,t return any value.
  • echo is faster than print.
  • It can accept multiple expressions.

Echo Example->

For Example (pass multiple argument)

Now we want to print all three variable values together. all variables names are define inside the echo statement separated by comm or dot(,or.) it will show the output.

What is Print

  • It is also a statement which is used to display the output and used with the parentheses print() or without the parentheses print.
  • It cannot accept multiple expressions.
  • It is slower than echo as it return a value.
  • It cannot pass multiple argument
  • It always return the value 1.

Example-> now we want to print the name. we simply define $name inside print statement with or without parentheses.
It will show the output: “dharmu”.

For Example (pass multiple argument)

Declare three variable $name, $profile, $age and hold the value (“dharmu,”php developer”,25).
Now check whether it will allow executing multiple arguments.
Pass three variables inside the print statement separated by a comma. As we run this program it shows error.
It means multiple arguments are not allowed in print.

Output: Parse error: syntax error

For Example (Check return type)

Output:
dharmu
In the above example
declare a variable $name hold value=”dharmu”.now we check the return type of print.
So (Print $name) is store in a variable ($ret).
it will show $name value with return type=1.

These other Difference Between echo and print in PHP

Find Trusted Cardiac Hospitals

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

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Encryption using RSA public and Private Key using PHP

PHP's OpenSSL extension can create an RSA key pair, encrypt data with the public key and decrypt it with the private key. This page explains the gist…

Read More

Encryption using Public key and Private key in PHP using mySql database

This tutorial shows how to generate an RSA key pair with PHP's OpenSSL extension, encrypt form input with the public key, store the ciphertext in MySQL, and…

Read More

How to see number of emails sent using smtp in laravel

Laravel does not count or log SMTP emails by default, so a grep will only return a real number once your application writes one log line for…

Read More

What are the Authentication type in phpmyadmin which for config.inc.php

phpMyAdmin supports four authentication types, set per server with $cfg['Servers'][$i]['auth_type'] in config.inc.php: cookie (the default), config, http and signon. This page explains how each one works and…

Read More

What is opcache and Install / Configure in Linux

OPcache is PHP's built-in bytecode cache. It keeps compiled scripts in shared memory so PHP doesn't have to parse and compile the same files on every request….

Read More

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