欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2023-12-24 19:47:03
...
好奇怪啊,往记事本里添加数据,用\t分割,结果到记事本里一看,各个tab键的长度不一致?

见图


回复讨论(解决方案)

木有人回答么

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













Item

Quantity

Tires


oil


Spark plugs


Shop Address















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!";

?>

上一篇:

下一篇: