Output function in php

Print :

This function displays output on browse and returns value true if output is printed successfully, otherwise it returns false.

Example

 

 

Output:   codelack<br/>1

Echo:

  •  It is  same as print but it does not return any value so  that its performance is faster than print function.
  • We can also print multiple statements with an echo function.

Example

 

 

Output: codelackcomtutorial.

 

var-dump:

using this function we can display the value of variable along with data types.

 

 

Output: int (100) string 8  codelack

Printf:-

Using this function we can print variables with the help of format specifiers.

 

 

Output :  100 codelack

Print_r: 

Using this function, we can display  all elements of array and properties of object.

 

 

Output:  array

[0]=10

[1]=20

[3]=40

[4]=50

 

NOTE : On viewing the source code , the array is shown systematically on the screen.

Scroll Up