Maison  >  Article  >  développement back-end  >  $line[一] = intval($line[1]); //这个这样写是什么意思

$line[一] = intval($line[1]); //这个这样写是什么意思

WBOY
WBOYoriginal
2016-06-13 12:32:161083parcourir

$line[1] = intval($line[1]); //这个这样写是什么意思?

<?php<br />
  //create short variable name<br />
  $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];<br />
?><br />
<html><br />
<head><br />
  <title>Bob's Auto Parts - Customer Orders</title><br />
</head><br />
<body><br />
<h1>Bob's Auto Parts</h1><br />
<h2>Customer Orders</h2><br />
<?php<br />
  //Read in the entire file.<br />
  //Each order becomes an element in the array<br />
  $orders= file("$DOCUMENT_ROOT/../orders/orders.txt");<br />
<br />
  // count the number of orders in the array<br />
  $number_of_orders = count($orders);<br />
<br />
  if ($number_of_orders == 0) {<br />
    echo "<p><strong>No orders pending.<br />
          Please try again later.</strong></p>";<br />
  }<br />
<br />
  echo "<table border=\"1\">\n";<br />
  echo "<tr><th bgcolor=\"#CCCCFF\">Order Date</th><br />
            <th bgcolor=\"#CCCCFF\">Tires</th><br />
            <th bgcolor=\"#CCCCFF\">Oil</th><br />
            <th bgcolor=\"#CCCCFF\">Spark Plugs</th><br />
            <th bgcolor=\"#CCCCFF\">Total</th><br />
            <th bgcolor=\"#CCCCFF\">Address</th><br />
         <tr>";<br />
<br />
  for ($i=0; $i<$number_of_orders; $i++) {<br />
    //split up each line<br />
    $line = explode("\t", $orders[$i]);<br />
<br />
    // keep only the number of items ordered<br />
    $line[1] = intval($line[1]); <br />
    $line[2] = intval($line[2]);<br />
    $line[3] = intval($line[3]);<br />
<br />
    // output each order<br />
    echo "<tr><br />
             <td>".$line[0]."</td><br />
             <td align=\"right\">".$line[1]."</td><br />
             <td align=\"right\">".$line[2]."</td><br />
             <td align=\"right\">".$line[3]."</td><br />
             <td align=\"right\">".$line[4]."</td><br />
             <td>".$line[5]."</td><br />
          </tr>";<br />
  }<br />
<br />
  echo "</table>";<br />
?><br />
</body><br />
</html><br />


 $line[1] = intval($line[1]); //这个这样写是什么意思? intval手册是这样描述intval通过使用特定的进制转换(默认是十进制),返回变量 var 的 integer 数值。但是将这个integer数值赋给$line[1]起到什么作用?

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn