echo(),print(),print_r()之间的区别?
时间:2023-11-15 08:52:42
echo是PHP语句, print和print_r是函数,语句没有返回值,函数可以有返回值(即便没有用)
print只能打印出简单类型变量的值(如int,string)
print_r可以打印出复杂类型变量的值(如数组,对象)
echo -- 输出一个或者多个字符串
Description
void echo ( string arg1 [, string ...] ) //返回值为空
echo "你好"," 朋友";
print --输出一个字符串
Description
int print ( string arg )//返回值为整形
print "你好朋友";
可以进行下面操作
$name=print "nihao \n";
$str = 'test print value is $name .';
eval("$print=\"$str\";");
echo $print;
print_r -- 打印关于变量的易于理解的信息。
bool print_r ( mixed expression [, bool return] ) //返回值是布尔型的,参数是mix类型的,可以是字符串,整形,数组,对象类print_r() 显示关于一个变量的易于理解的信息。如果给出的是 string、integer 或 float,将打印变量值本身。如果给出的是 array,将会按照一定格式显示键和元素。object 与数组类似。
print_r() 将把数组的指针移到最后边。
你可以
print_r(str);
print_r(int);
print_r(array);
print_r(obj);
也可以用var_dump var_export
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
开心网上input输入框研究
![](https://img.aspxhome.com/file/UploadPic/20093/6/1207fc9f5fag215-89s.jpg)
详解mysql 获取某个时间段每一天、每一个小时的统计数据
![](https://img.aspxhome.com/file/2023/4/113974_0s.jpg)
使用Python制作自动推送微信消息提醒的备忘录功能
![](https://img.aspxhome.com/file/2023/3/112393_0s.jpg)
Python实现发送QQ邮件的封装
![](https://img.aspxhome.com/file/2023/9/97269_0s.jpg)
Django 全局的static和templates的使用详解
![](https://img.aspxhome.com/file/2023/4/99694_0s.png)
解析Python3中的Import
python调用pyaudio使用麦克风录制wav声音文件的教程
Python Numpy 数组的初始化和基本操作
vscode调试container中的程序的方法步骤
![](https://img.aspxhome.com/file/2023/8/130898_0s.png)
Python利用heapq实现一个优先级队列的方法
![](https://img.aspxhome.com/file/2023/6/89446_0s.jpg)
python加速器numba使用详解
利用python操作SQLite数据库及文件操作详解
sql 判断数据库,表,存储过程等是否存在的代码
javascript实现文字无缝滚动效果
关于Vue的URL转跳与参数传递方式
![](https://img.aspxhome.com/file/2023/3/128883_0s.png)
Python获取当前脚本文件夹(Script)的绝对路径方法代码
Python数据结构之栈、队列的实现代码分享
![](https://img.aspxhome.com/file/2023/7/121617_0s.png)
Python3.6实现连接mysql或mariadb的方法分析
Python实现正弦信号的时域波形和频谱图示例【基于matplotlib】
![](https://img.aspxhome.com/file/2023/5/103535_0s.png)