<?php
echo "檔案路徑:{$_SERVER["PHP_SELF"]}<br>";
echo "IP位置:{$_SERVER["REMOTE_ADDR"]}<br>";
echo "瀏覽器:{$_SERVER["HTTP_USER_AGENT"]}<br>";
?>
2013-09-11
2013-09-10
php 星期幾 + $$使用方法時機
話不多說看程式碼
正常寫法
<?
$Sunday="星期日";
$Monday="星期一";
$Tuesday="星期二";
$Wednesday="星期三";
$Thursday="星期四";
$Friday="星期五";
$Saturday="星期六";
$today=date("l"); //l==L date("l") php函數 取得星期幾]
if($today=="Sunday"){
echo "<br>今天是{$Sunday}";
}elseif($today=="Monday"){
echo "<br>今天是{$Monday}";
}
elseif($today=="Tuesday"){
echo "<br>今天是{$Tuesday}";
}
elseif($today=="Wednesday"){
echo "<br>今天是{$Wednesday}";
}
elseif($today=="Thursday"){
echo "<br>今天是{$Thursday}";
}
elseif($today=="Friday"){
echo "<br>今天是{$Friday}";
}
elseif($today=="Saturday"){
echo "<br>今天是{$Saturday}";
}
echo "<br>";
echo "<br>";
echo "使用$$";
echo "<br>今天是{$$today}";
?>
使用$$可以少寫很多的if
但結果都一樣
正常寫法
<?
$Sunday="星期日";
$Monday="星期一";
$Tuesday="星期二";
$Wednesday="星期三";
$Thursday="星期四";
$Friday="星期五";
$Saturday="星期六";
$today=date("l"); //l==L date("l") php函數 取得星期幾]
if($today=="Sunday"){
echo "<br>今天是{$Sunday}";
}elseif($today=="Monday"){
echo "<br>今天是{$Monday}";
}
elseif($today=="Tuesday"){
echo "<br>今天是{$Tuesday}";
}
elseif($today=="Wednesday"){
echo "<br>今天是{$Wednesday}";
}
elseif($today=="Thursday"){
echo "<br>今天是{$Thursday}";
}
elseif($today=="Friday"){
echo "<br>今天是{$Friday}";
}
elseif($today=="Saturday"){
echo "<br>今天是{$Saturday}";
}
echo "<br>";
echo "<br>";
echo "使用$$";
echo "<br>今天是{$$today}";
?>
使用$$可以少寫很多的if
但結果都一樣
2013-09-09
訂閱:
文章 (Atom)