热搜:NVER node 开发 php

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

2024-08-12 14:25:02
好奇怪啊,往记事本里添加数据,用t分割,结果每个tab键的长度不一致?不一致?

好奇怪啊,往记事本里添加数据,用\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


     <?php
     echo "

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

";
     ?>

<?php
$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!";

?>