print() function in PHP


The print() function in PHP outputs one or more string.

Note − The print() function is slower than echo()

Syntax

print(arg)

Parameters

  • arg − The input data

Return

The print() function always return 1.

Example

The following is an example −

Live Demo

<?php
   $s = "This is demo text!";
   print $s;
?>

Output

This is demo text!

Example

The following is an example −

Live Demo

<?php
   $one = "Java is a programming language!";
   $two = "James Gosling developed Java!";
   $three = "Current version of Java is Java SE 11!"; 
   print $one . " " . $two . " " .$three;
?>

Output

Java is a programming language! James Gosling developed Java! Current version of Java is Java SE 11!

Example

The following is an example −

Live Demo

<?php
   print "This is a demo
   text in
   multiple lines.";
?>

Output

This is a demo text in multiple lines.

Updated on: 30-Jul-2019

210 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements