PHP Print

PHP Print

Like PHP echo, PHP print is a language construct, so you don't need to use parenthesis with the argument list. Unlike echo, it always returns 1.
The syntax of PHP print is given below:

int print(string $arg)  

PHP print statement can be used to print string, multi line strings, escaping characters, variable, array etc.


PHP print: Printing String

<?php  
    print "Hello";  
    print ("Welcome to w3professors.com ");  
?>  
Output : HelloWelcome to w3professors.com

PHP echo: Printing Multi Line String

<?php  
    print "Hello by PHP print  
    this is multi line  
    text printed by   
    PHP print statement  
    ";  
?>  
Output : Hello by PHP print this is multi line text printed by PHP print statement

PHP echo: Printing Escaping Characters

<?php  
    print "Hello escape \"sequence\" characters by PHP print";  
?>  
Output : Hello escape "sequence" characters by PHP print

PHP echo: printing variable value

<?php  
    $msg="Hello print() in PHP";  
    print "Message is: $msg";    
?>  
Message is : Hello print() in PHP