group-icon
PHP Programming
Group for all things PHP, Coding Help, Problems and Solutions
104 Members
Join this group to post and comment.
AdhikariHarika Reshma
AdhikariHarika Reshma
Computer Science
24 Jan 2019

What are the different types of print functions available in php?

PHP is a server side scripting language for creating dynamic web pages.There are so many functions available in to display output in php. Here,I will explain some basic functions for displaying output in php. They are:

1.print() Function:Using this function we can display the outputs in the browser.This function returns the Boolean value true.We cannot print multiple statements using this function.The print function plays same role as echo function.

2.echo() Function:The echo function outputs one or more strings.using this function we can display multiple statements in the browser.The echo() function is slightly faster than the print() function as it doesn't return a value.

3.printf() Function:The printf() function is also used in C,C++.It outputs  a formatted string.With the help of formats specified we can display the output.

4.sprintf() Function:The sprintf() function writes a formatted string to a variable.This is same as printf but instead of displaying the output on the web page,it returns that output.sprintf() prints the result to a string.

5.var_dump() Function:It displays the information of  a variable that includes its type and value.This function displays the variable value along with the variable data type. The var_dump() function is used t display structured information about one or more variables.

6.print_r() Function:The print_r() php function is used to return an array in  a human readable form.This function displays the elements of an array and properties of an object.It displays human readable information about a variable. 


Shruthi Pillai
Shruthi Pillai
Information Technology
2mos ago

The basic functions for displaying output in PHP are as follows:

  • Print() Function
  • Echo() Function
  • Printf() Function
  • Sprintf() Function
  • Var_dump() Function
  • Print_r() Function