TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PHP Print

PHP print for beginners and professionals with examples, php file, php session, php date, php array, php form, functions, time, xml, ajax, php mysql, regex, string, oop

<< Back to PHP

PHP Print

Like 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:

  • print is a statement, used as an alternative to echo at many times to display the output.
  • print can be used with or without parentheses.
  • print always returns an integer value, which is 1.
  • Using print, we cannot pass multiple arguments.
  • print is slower than the echo statement.

PHP print: printing string

File: 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 string

File: 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 characters

File: print3.php

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

Output:

Hello escape "sequence" characters by PHP print

PHP print: printing variable value

File: print4.php

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

Output:

Message is: Hello print() in PHP





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf