Home  >  Article  >  Backend Development  >  好奇怪啊,往记事本里添加数据,用t分割,结果每个tab键的长度不一致?不一致?

好奇怪啊,往记事本里添加数据,用t分割,结果每个tab键的长度不一致?不一致?

WBOY
WBOYOriginal
2016-06-23 13:40:291901browse

好奇怪啊,往记事本里添加数据,用\t分割,结果到记事本里一看,各个tab键的长度不一致?

见图


回复讨论(解决方案)

木有人回答么

源代码如下,是两个文件,一个提交数据,一个处理数据。

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">







    
    



Item

Quantity

Tires


oil


Spark plugs


Shop Address





    

    





nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Order Results



    
    

Bob's auto Parts


    

Order Results


          echo "

Order Precessed at ";
     echo date('H:i,jS F');
     echo "

";
     ?>

$totalqty = 0;
print_r($_POST);
echo "
";

$tireqty = $_POST['tireqty'];
$oilqty  = $_POST['oilqty'];
$sparkqty= $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$totalqty = $tireqty+$oilqty+$sparkqty;
$date = date('H:i,jS F Y');
echo "Item Ordered: $totalqty
";
if ($totalqty==0) {
    echo "You did not order anything on the Bob's site!";
} else {
    if ($tireqty>0) {
        echo $tireqty."tireqty
";
    } 
    if ($oilqty>0){
        echo $oilqty."oilqty
";
    }
    if ($sparkqty>0) {
        echo $sparkqty."sparkqty
";
    }
}

$totalamount = 0.00;

define('TIREPRICE', 100);
define('OLIPRICE', 10);
define('SPARKPRICE', 4);
$totalamount =  $tireqty*TIREPRICE
+$oilqty*OLIPRICE
+$sparkqty*SPARKPRICE;
$totalamount = number_format($totalamount,2,'.','');
echo "

Totalamount is $".$totalamount."

";
$tax_rate = 0.1;
$totalamount = $totalamount*(1+$tax_rate);
echo "Total including tax:$".$totalamount."
";

$putstrings =$date."\t".$tireqty." tires\t".$oilqty." oil\t".$sparkqty." spark plugs\t"."Totalamount $".$totalamount."\t"."Address ".$address."\r\n";
print_r($DOCUMENT_ROOT);
@$fp = fopen("$DOCUMENT_ROOT/../orders/order.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp) {
    echo "

your order is not processed at this time.
    Please try again later.

";
    exit;
}
fwrite($fp, $putstrings,strlen($putstrings));
flock($fp, LOCK_UN);
fclose($fp);
echo "Order Written!";

?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn