Hello world
Hello World
2015年12月26日 星期六
[PHP教學] Lesson 1. $變數(variables), function, and for迴圈(for loop)
2015/12/25 Lesson 1. $變數(variables), function, and for迴圈(for loop)
<?php
// 2015/12/25 Lesson 1. $變數(variables), function, and for迴圈(for loop)
$love = '<3';
$j = 'Jacinda'; // This is the man's lover.
$k = 'Kevin';
$cash = 12000; // This is all I have in cash.
$b = 'Brandon';
$c = 'Courtney';
$bc = 501;
echo $k . ' ' . $love . ' '. $j . '</br>';
function love($man, $woman, $atm) {
$gift = 499; // This is the product price.
echo $man . ' buy a gift for ' . $woman . ' spends ' . $gift;
echo ' so he only have ' . ($atm - $gift) . ' left.</br>';
}
love($k, $j, $cash);
love($b, $c, $bc);
love('William', $j, 499);
$apple = 10; // Apple farm have 10 apples.
$kevin = $apple; // Kevin owns the apple farm.
$sum = $kevin; // Total apple count equals to the amount of apple that Kevin owns.
$apple_dayborn = 2; // The amount of apple produced daily: 2.
$day = 5; // The days that apple is being produced.
for($i = 1; $i <= $day; $i++) {
$sum+= $apple_dayborn; // $sum = 10 + 2/day
}
// (((((10) +2) +2) +2) +2) +2 = 20
echo $k . ' produce ' . $sum . ' apples.</br>';
for($i = 1; $i <= 5; $i++) {
echo 'love';
}
/* 1. start
$i = 1; // give 1 for $i.
2. stop
$i <= 3; // $i <= 3.
3. do?
$i++;
*/
?>
訂閱:
張貼留言
(
Atom
)
沒有留言 :
張貼留言
提供匿名留言,歡迎留言詢問 ^ ^