print() function in PHP

PHPProgrammingServer Side Programming

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.
raja
Updated on 30-Jul-2019 22:30:23

Advertisements