以下是一个简单的PHP实例,用于计算不同产品的产量。该实例将展示如何使用PHP进行基本的数学运算,并将结果以表格的形式展示。
```php
// 定义产品数据
$products = [
'Product A' => 10,
'Product B' => 20,
'Product C' => 30
];
// 定义每个产品的生产速度(单位:件/小时)
$production_speed = [
'Product A' => 5,
'Product B' => 3,
'Product C' => 4
];
// 定义当前时间(小时)
$current_time = 8; // 假设当前时间为8小时
// 计算每个产品的产量
$production_output = [];
foreach ($products as $product => $quantity) {
$production_output[$product] = $quantity * $production_speed[$product] * $current_time;
}
// 打印表格
echo "