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 −
<?php $s = "This is demo text!"; print $s; ?>
Output
This is demo text!
Example
The following is an example −
<?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 −
<?php print "This is a demo text in multiple lines."; ?>
Output
This is a demo text in multiple lines.