当前位置:Gxlcms > PHP教程 > 好奇怪啊,往记事本里添加数据,用t分割,结果每个tab键的长度不一致?不一致?

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

时间:2021-07-01 10:21:17 帮助过:66人阅读

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

见图


回复讨论(解决方案)

木有人回答么

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




















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

?>

这是记事本的问题,你用 notepad++之类的编辑器打开文本文件就好了。

这个与tab等于多少空格有关。记事本貌似是是8。

人气教程排行