• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Web development » PHP » Print/echo statement in PHP

Print/echo statement in PHP

June 7, 2020 by techgoeasy Leave a Comment

print in php

Print/echo statement

(1) Like python or other programming language, Print in PHP or echo in PHP does the same job i.e printing the statement on the screen

Example
<?php
print "This is php script";
echo " This is php script";
?>

This is php script
This is php script

So it is obvious from the above code, it just print the same character as it is and it is quite simple to use.

(2) Just like any other programming language , print statement print the variable name in the same manner as given below

<?php
$x=10
print "This is $x";
echo " This is $x";
?>

This is 10
This is 10

(3) The behavior with single quotes is different

<?php
$x=10
print 'This is $x';
echo "This is $x";
?>

This is $x
This is 10

So if you enclose the statement in single quotes, variable are not substituted for their value and they are printed as just they are word.

(4) PHP Array can be printed as below

<?php
$oracle_product = array("hyperion", "database", "weblogic", "sql", "EBS");

foreach($oracle_product as $value){
echo $value . "<br>";
}
?>

So you basically iterate through the array using for loop and print the each element in the array. This is quite useful

Hope you like post on print in PHP

Also Reads
How to run php file in windows : This post talks about how we can php file on the the window and do the testing before moving to the web server
uses of PHP : This has detailed description why PHP is so much used through out the world.
first php program : This is good starting point for anybody starting with PHP and talk in good detail about how to write your PHP program and execute it
Define constant in PHP
PHP Array functions
PHP String Functions
https://en.wikipedia.org/wiki/PHP

Filed Under: PHP, Web development

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to generate sql monitor report in Oracle
  • How to find the long running (longops session) in Oracle
  • How to find concurrent request id from Sid or spid
  • how to check recycle bin in oracle: Purge, enable/disable
  • how to check fra size in oracle: Location, usage, change size

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us