为什么我在数据库中看到alex1而不是alex? [英] Why I am seeing alex1 instead of alex which is in database?

查看:90
本文介绍了为什么我在数据库中看到alex1而不是alex?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码



I use this code

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

';



返回视图('hello');

}



我在浏览器上看到这个





[ ^ ]



这是我的数据库图片。我正在使用亚历克斯。



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



那么,为什么我在浏览器的第一个结果中看到alex1?

';

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?

推荐答案

user = User :: find(1) - >用户名;
echo'< pre>' ,print_r(
user = User::find(1)->username; echo '<pre>' , print_r(


user),'

';



返回视图('hello') ;

}



我在浏览器上看到这个





[ ^ ]



这是我的数据库图像。我正在使用亚历克斯。



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



那么,为什么我在浏览器的第一个结果中看到alex1?

';

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?


因为你是 echo - 完成作业打印后 print_r()的返回值
Because you're echo-ing the return value of print_r() after it has done its job printing


这篇关于为什么我在数据库中看到alex1而不是alex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆