我发现了一些奇怪的行为,无法解释发生了什么:
<!DOCTYPE html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/normalize.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/vendor/modernizr.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/vendor/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="row">
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
<div class="small-6 columns text">i some text</div>
</div>
</body>
</html>
给出:
$e = 3;
echo "with array " . print_r($e);
为什么?
答案 0 :(得分:4)
在任何输出之前完成连接:
echo "with array " . print_r($e);
是
print_r
的结果。 print_r
打印3
和returns TRUE
。with array
字符串与TRUE
连接。 TRUE
的字符串表示形式为1
。3with array 1
如果您希望print_r
返回值而不是打印它,请使用它的第二个参数:
echo "with array " . print_r($e, true); // `with array 3`