<?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行,是用","号作为连接符,在测试的时候竟然可以通过.当然,他的书中用的是“.”符号。
我就纳闷了 逗号怎么也能当连接符的吗?

解决方案 »

  1.   

    for "echo"
    echo — Output one or more strings
      

  2.   

    这不是从C开始带过来的习惯嘛。printf这类的输出都是变参的。echo也继承了这个优良传统。
    这里的逗号是参数间隔符,不是字符串连接符。
      

  3.   

    很正常啊,echo 的东西你甚至可以不加引号echo asg,awegawegawe,gawe,aweg,awegw,aeghw,eh,we,h;
      

  4.   

    ,不是连接符号!
    echo 支持多个参数,他们是多个参数之间的分隔符!
    print 不支持多个参数的!echo 如果带括号的话就和print一样了!
      

  5.   

    这个不是连接符。晕菜。
    $str1 = 1;
    $str2 = 2;
    $str3 = '....';
    echo $str1,$str2,$str3;---------- PHP调试 ----------
    12....
    输出完成 (耗时: 0 秒) - 正常终止