C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
PHP PrintLike PHP echo, PHP print is a language construct, so you don't need to use parenthesis with the argument list. Print statement can be used with or without parentheses: print and print(). 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 the string, multi-line strings, escaping characters, variable, array, etc. Some important points that you must know about the echo statement are:
PHP print: printing stringFile: print1.php <?php print "Hello by PHP print "; print ("Hello by PHP print()"); ?> Output: Hello by PHP print Hello by PHP print() PHP print: printing multi line stringFile: print2.php <?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 print: printing escaping charactersFile: print3.php <?php print "Hello escape \"sequence\" characters by PHP print"; ?> Output: Hello escape "sequence" characters by PHP print PHP print: printing variable valueFile: print4.php <?php $msg="Hello print() in PHP"; print "Message is: $msg"; ?> Output: Message is: Hello print() in PHP
Next TopicPHP echo and print Statements
|