<?php
# Script 1.9 - numbers.php// Set the variables.
$quantity = 30; // Buying 30
$price = 119.95; // $119.95
$taxrate = .05; // 5%// Calculate the total.
$total = $quantity * $price;
$total = $total + ($total * $taxrate); // Add tax.
$total = number_format ($total, 2); // Format the results.// Print the results.
echo 'You are purchasing <b>', $quantity, '</b> widget(s) at a cost of <b>$', $price. '</b> each. With tax, the total comes to <b>$', $total, '</b>.';
?>这是老外写的一本书附带的源代码中的示范,看这段书中的代码,最后4行,是用","号作为连接符,在测试的时候竟然可以通过.当然,他的书中用的是“.”符号。
我就纳闷了 逗号怎么也能当连接符的吗?
# Script 1.9 - numbers.php// Set the variables.
$quantity = 30; // Buying 30
$price = 119.95; // $119.95
$taxrate = .05; // 5%// Calculate the total.
$total = $quantity * $price;
$total = $total + ($total * $taxrate); // Add tax.
$total = number_format ($total, 2); // Format the results.// Print the results.
echo 'You are purchasing <b>', $quantity, '</b> widget(s) at a cost of <b>$', $price. '</b> each. With tax, the total comes to <b>$', $total, '</b>.';
?>这是老外写的一本书附带的源代码中的示范,看这段书中的代码,最后4行,是用","号作为连接符,在测试的时候竟然可以通过.当然,他的书中用的是“.”符号。
我就纳闷了 逗号怎么也能当连接符的吗?
echo — Output one or more strings
这里的逗号是参数间隔符,不是字符串连接符。
echo 支持多个参数,他们是多个参数之间的分隔符!
print 不支持多个参数的!echo 如果带括号的话就和print一样了!
$str1 = 1;
$str2 = 2;
$str3 = '....';
echo $str1,$str2,$str3;---------- PHP调试 ----------
12....
输出完成 (耗时: 0 秒) - 正常终止