Click here to Skip to main content
15,920,656 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I use this code

public function home(){
     echo $user = User::find(1)->username;
    echo '<pre>' , print_r($user), '
';

return view('hello');
}

I see this on my browser


[^]

This is my database image. I am using alex.

http://tinypic.com/r/2py9ekx/9[^]

So, why should i see alex1 in first result on my browser?
Posted

1 solution

Because you're echo-ing the return value of print_r() after it has done its job printing $user.

Use this code
PHP
echo print_r($user,1);
to grab the output of print_r().
 
Share this answer
 
Comments
ankur1163 9-Dec-15 4:29am    
I just want to know why it is happening. Return value of print_r is alex1?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900