Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中执行字符串连接时优先级错误_Php_String_Echo_String Concatenation - Fatal编程技术网

在php中执行字符串连接时优先级错误

在php中执行字符串连接时优先级错误,php,string,echo,string-concatenation,Php,String,Echo,String Concatenation,代码非常简单: echo 'RESP:'.$db->printList($pprofile); 什么db->printList($pprofile)的作用是打印更多的字符串。我基本上是把字符串RESP放在db->printList($pprofile)返回的值之前 问题是结果是相反的。如果db->printList($pprofile)返回A,然后我总是得到这个:A:RESP,而我期望RESP:A 我从来没有遇到过这样的问题,我很困惑。我在许多其他地方(使用其他类型的输入/输出)在同一个

代码非常简单:

echo 'RESP:'.$db->printList($pprofile);
什么
db->printList($pprofile)的作用是打印更多的字符串。我基本上是把字符串
RESP
放在
db->printList($pprofile)返回的值之前

问题是结果是相反的。如果
db->printList($pprofile)
返回
A
,然后我总是得到这个:
A:RESP
,而我期望
RESP:A


我从来没有遇到过这样的问题,我很困惑。我在许多其他地方(使用其他类型的输入/输出)在同一个脚本中做了非常类似的事情,并得到了正确的结果。有什么想法吗?

printList
不返回值,它会打印它,这就是为什么您使用相反的顺序(方法在连接期间执行,值被打印,然后字符串被连接,方法不返回任何内容,并使用
echo
打印)

它实际上不打印<代码>打印列表
只返回我描述的值,echo打印它。尝试在没有echo的情况下运行它,没有其他方法可以像您描述的那样颠倒顺序here@hsnm-你不是这么说的。Quote:“
db->printList($pprofile);
所做的是打印更多的字符串。”@lupatus你说得对。我想这是我的问题。我将尝试仔细查看。显示
printList()
的代码。