我们以一个提交订单和显示订单信息的例子为学习PHP的开始。这个例子包含两个文件。一个提交订单的html文件:orderform.html,一个显示订单信息的PHP文件:processorder.PHP。我将这两个文件放在test_1文件夹下,将test_1文件夹放在htdocs目录下。 文件的组织形式如下图所示,使用xampps安装的集成环境。
提交订单的html文件orderform.html如下所示:
PHP" method="post">
显示订单信息的PHP文件processorder.PHP如下所示:
PHP;">
Bob 's Auto Parts - Order Results
"; echo $oilqty.' bottles of oil
'; echo $sparkqty." spark plugs
" ?> ---------------------------------------------------
PHP $testHeredoc = <<< EOF line 1 line 2 line 3 EOF; echo "$testHeredoc"."
"; ?> ---------------------------------------------------
<!DOCTYPE html>
@H_404_20@Bob 's Auto Parts
Order Results
PHP echo "Order processed at "; echo date('H:i,jS F Y')."
"; echo "Your order is as follows:
"; echo "$tireqty tires"; echo $oilqty.' bottles of oil
'; echo $sparkqty." spark plugs
" ?> ---------------------------------------------------
PHP $testHeredoc = <<< EOF line 1 line 2 line 3 EOF; echo "$testHeredoc"."
"; ?> ---------------------------------------------------