Why do print_r and var_dump execute before echo

后端 未结 3 392
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 01:52

I\'m calling either var_dump() or print_r() on an array that has one value in an echo statement:

echo \"
<
3条回答
  •  天涯浪人
    2020-12-12 02:45

    var_dump doesn't return anything, it does its own printing. It evaluates first, since PHP can't concatenate an expression of which it doesn't know the value. You probably want:

    echo "

    testArray is ==> "; var_dump($testArray); echo " <===

    ";

    instead. Print the start, the middle, then the end.

提交回复
热议问题