Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "1" mean at the end of a php print_r statement?

Tags:

php

My print_r($view) function yields:

View Object (     [viewArray:View:private] => Array         (             [title] => Projet JDelage         ) ) 1 <-------------- 

What does the "1" at the end mean? The PHP manual isn't very clear on how to parse the output of print_r.

like image 678
JDelage Avatar asked Sep 22 '10 15:09

JDelage


People also ask

What does Print_r mean in PHP?

print_r(variable, isStore) It is a built-in function in print_r in PHP that is used to print or display the contents of a variable. It essentially prints human-readable data about a variable. The value of the variable will be printed if it is a string, integer, or float.

Which is correct syntax of Print_r () function?

If the parameter $isStore is set to TRUE then the print_r() function will return a string containing the information which it is supposed to print. print_r( $var1 ); echo "\n" ; print_r( $var2 );

Why do we use Print_r?

It is an inbuilt function that is used in PHP to print or display the information stored in a variable. Basically it prints human-readable information about a variable. If the variable is a string, integer or float, the value itself will be printed.

What is difference between ECHO and Print_r in PHP?

The print and echo are both language constructs to display strings. The echo has a void return type, whereas print has a return value of 1 so it can be used in expressions. The print_r is used to display human-readable information about a variable.


1 Answers

You probably have echo print_r($view). Remove the echo construct. And... what need do you have to parse its output? There are certainly much better ways to solve your problem.

like image 101
Ionuț G. Stan Avatar answered Sep 21 '22 21:09

Ionuț G. Stan