∮Ω奧米加空間∮»PHP 交流區»【討論】各類語法應用
| 作者 |
主題 分頁:[ 1 2 ] |
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 1 篇) 【討論】各類語法應用
連結文字取消底線
將下列語法貼於</HEAD>之前:
<style>
<!--
A{text-decoration:none}
-->
</style>
-------------------------------------------------------------------------------------------
半透明語法
首先,先複製以下語法至<head>和</head>之間
<STYLE>table{filter:Alpha(Opacity=50, FinishOpacity=50, Style=2)}</STYLE>
table 這裡可以隨意更改,目前設為table表示所有的表格皆為半透明
Opacity=50 此為起始點透明度度,數字越高越透明(0~100)
FinishOpacity=50 此為結束點透明度,數字越高越透明(0~100)
Style=2 這個是透明類型,可自行選擇(1~3)
這次教學就這麼簡單,另外,"Opacity"與"FinishOpacity"數字的相近與否會影響到整體的視覺,站長把它們的差設為10,比如Opacity設為 70,則FinishOpacity設為80會比較好~這只是個建議啦,你們可以自己玩玩看~
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-06-18 23:18 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 2 篇)
檢測客戶端安裝字體的JS代碼
<html>
<script>
function testFonts()
{
var a=dlgHelper.fonts.count;
a="一共" + a+" 種字體";
alert(a); //show total number of system fonts
for (i = 1;i < dlgHelper.fonts.count;i++)
{
var f= f+"{"+i+"}"+ dlgHelper.fonts(i) +"; "
}
alert(f); //show names of all system fonts
}
</script>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>新增網頁2</title>
</head>
<body >
<p align="center">
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px" style="border-style: groove; border-width: 1" align="absmiddle"></OBJECT>
</p>
<p align="center" onclick=testFonts()><font face="SimHei"><span title="點擊測試">
<font color="#000080"><a href=# style="text-decoration: none">
<font color="#000080">字體測試</font></font></span><font color="#000080"><a href=# style="text-decoration: none"><font color="#000080">
</font></a></font></font>
</body>
</html>
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-06-21 13:08 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 3 篇)
MYSql root 密碼忘了,可按照下列方式更正:
1.先停掉mysql
# /etc/rc.d/init.d/mysql stop
2.以--skip-grant-table 的參數啟動mysql
# safe_mysql --skip-grant-table&
3. 更改root 密碼
# mysql mysql
mysql> UPDATE user SET password=password('newpassword'
WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.停掉mysql再重跑
# mysqladmin -uroot -p shutdown
Enter password: //輸入新設定的密碼
# /etc/rc.d/init.d/mysql start
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-06-25 01:54 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 4 篇)
如何在php中生成隨機顏色
<?
error_reporting(0);
function rcolor() {
srand((double)microtime()*10000000);
$rand = (rand(30,170));
return sprintf("%02X","$rand");
}
function rand_color($string) {
$array = explode(" ",$string);
$j = count($array);
for ($i=0;$i<$j;$i++) {
$return .= '<font color="#'.rcolor().rcolor().rcolor().'">'.$array[$i].' </font>'; }
return $return;
}
?>
現在用上面的函數試試。
<html>
<body bgcolor="#FFFFFF">
<h3>
<?
echo rand_color("可以生成很多種隨機的顏色,不錯!");
?>
</h3>
</body>
</html>
本帖由dc最後編輯於2002-06-25 02:17
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-06-25 02:17 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 5 篇)
如何在php中隨機生成密碼
# 說明: 1. 可以在'$possible_charactors'中加入更多字元、數位。
# 2. 可以改變這個密碼串的長度,例如,
# echo 'Random_Password(16);' 可以生成16位元字串.
<?
function Random_Password($length) {
srand(date("s"));
$possible_charactors = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while(strlen($string)<$length) {
$string .= substr($possible_charactors,(rand()%(strlen($possible_charactors))),1);
}
return($string);
}
echo Random_Password(8);
?>
本帖由dc最後編輯於2002-06-25 02:18
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-06-25 02:18 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 6 篇) 【轉貼】用 PHP 取得其他網頁的文字
用 PHP 取得其他網頁的文字
在你想加入該段文字的位置加入
<?
$url='http://url.net/;
$start = 開始的行數(HTML);
$end = 結束的行數(HTML);
//不要修改以下 PHP
$file=file($url);
for ($i=$start;$i<$end;$i++) {
print "$file[$i]\n";
}
?>
只需更改紅色的部份。
開始的行數應是那一行的上面一行,結束的行數應是那一行。
e.g.
1 abc
2 def
3 ghi
4 jkl
5 mno
如想取得 "ghi" ,開始行數是 2 ,結束行數是 3 。
如想取得 "ghi" 和 "jkl",開始行數是 2 ,結束行數是 4。
原始來源:http://www.pczonehk.com/view.php?type=homepage&cat=php&id=2
本帖由dc最後編輯於2002-08-15 18:20
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-08-08 04:01 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 7 篇) 【轉貼】
PHP 自動轉址
在你想的檔案加入
<?
Header ("Location:http://www.pczonehk.com");
?>
只需更改紅色的部份。
然後更改副檔名為 .php。
原始來源:http://www.pczonehk.com/view.php?type=homepage&cat=php&id=4
本帖由dc最後編輯於2002-08-15 18:17
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-08-08 04:05 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 8 篇)
使用PHP來維護檔案系統
PHP 提供了很多與檔案系統相關的函數,讓我們不僅可以開啟檔案,還能夠顯示目錄的內容,搬移檔案的位置以及其他更多方便的功能有人甚至寫了能夠透過瀏覽器來管理檔案內容的 PHP 程式。
在開始介紹 PHP 的檔案系統相關弁鄐妨e,我們要先釐清一件事情:在 Windows作業系統裡面,檔案路徑可以使用斜線(/)或者反斜線()來表示,但是在其他作業系統裡面我們只會使用到斜線。為了保持統一性,下面的範例裡面的檔案路徑都是使用斜線。
下面的範例程式教你基本的目錄內容顯示弁遄A每個步驟都有註解,請直接嬝炕C
<? /* $dir_name 這個變數的值是你想要讀取的目錄的完整路徑 */
$dir_name = "/home/me/";
/* opendir()函數會開啟某個目錄,並且傳回一個參考值(handle)讓我們可以用來在程式中參照到該目錄 */
$dir = opendir($dir_name);
/* 開始建立一個字串,這個字串包含了 HTML 的列表標籤,用來顯示目錄中的檔案名稱。 */
$file_list = "<ul>";
/* 使用一個 while 迴圈敘述將前面開啟的目錄中的檔案全部讀取一遍。如果讀取到的檔名不是「.」或者「..」,就把該檔名寫入前面提到的字串裡面去。 */
while ($file_name = readdir($dir)) {
if (($file_name != ".") && ($file_name != "..")) {
$file_list .= "<li>$file_name";
}
}
/* 替 HTML 列表標籤加上結尾 */
$file_list .= "</ul>";
/* 關閉之前開啟的目錄並且結束這段 PHP 程式 */
closedir($dir);
?>
<!-- HTML原始碼從這裡開始 -->
<HTML>
<HEAD>
<TITLE>列出目錄中的檔案名稱</TITLE>
</HEAD>
<BODY>
<!-- 使用 PHP 程式來將我們所讀取的目錄名稱顯示在頁面上 -->
<P>Files in: <? echo "$dir_name"; ?></p>
<!-- 使用 PHP 程式將該目錄中讀取到的檔名顯示在頁面上 -->
<? echo "$file_list"; ?>
</BODY>
</HTML>
恭喜!你已經成尼漎Y個目錄中的檔案名稱顯示在網頁上了。請記住一點:要讀取某個目錄或者檔案(讀取檔案內容的做法稍後會介紹),PHP 本身執行所用的身分必須至少擁有該目錄或者檔案的讀取權限才行,否則系統會顯示權限不足的錯誤訊息。
下一個範例教你如何複製一個檔案:
<? /* 變數$orginal儲存原始檔案的完整路徑,變數$copied儲存複製過去的新檔案的完整路徑 */
$original = "/home/me/mydatabasedump";
$copied = "/archive/mydatabasedumo_1010";
/* 呼叫 copy() 函數把檔案從原始位置複製一份到新的位置去。如果無法複製,那麼便終止程式的執行並且顯示錯誤訊息。 */
@copy($original, $copied) or die("無法複製檔案。");
?>
上面的範例程式可以用來擴充成為一個檔案備份系統程式。當這個程式執行的時候,它會將資料庫的資料檔案複製到其他目錄下面做為備份之用。只要修改系統的排程檔案內容(crontab),我們便可以讓這個程式自動在每天的固定時刻執行一次,達到系統自動備份,不需要人工手動執行。
如果你的系統上面有安裝 Lynx 軟體(Lynx 是一種純文字的 Web 瀏覽器)的話,你可以在系統排程檔案裡面加入下面這筆記錄來讓系統在固定時間自動啟動 Lynx 並且呼叫我們之前寫好的 PHP 備份程式。當 Lynx 呼叫(瀏覽)我們的 PHP 程式的時候,該程式就會被執行,並且產生備份檔案。下面這個範例教你如何在每天早晨五點鐘執行我們的備份程式,並且在執行完以後自動將 Lynx 程式關閉:
0 5 * * * [username] lynx -dump http://localhost/copyfile.php 1>/dev/null 2>&1
如果你的系統安裝的是 CGI 版本的 PHP,那麼你可以直接呼叫 PHP 執行檔而不需要透過 Lynx 來呼叫我們的 PHP 程式:
0 5 * * * [username] php /path/to/copyfile.php 1>/dev/null 2>&1
來源:SC
作者: HKMARCO
本帖由dc最後編輯於2002-08-08 17:33
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-08-08 17:32 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 9 篇)
用 PHP 將文字製成圖像
<?
header("content-type: image/png");
$png = ImageCreate(88,31);
$bg = ImageColorAllocate($png,255,255,255);
$tx = ImageColorAllocate($png,0,0,0);
ImageFilledRectangle($png,0,0,88,31,$bg);
ImageString($png,6,11,2,"test",$tx);
Imagepng($png);
ImageDestroy($png);
?>
程式解說:
header("content-type: image/png");
告訴瀏覽器這是一幅圖片。
$png = ImageCreate(88,31);
產生一幅 88*31 大小的圖片
$bg = ImageColorAllocate($png,255,255,255);
$tx = ImageColorAllocate($png,0,0,0);
色彩配置
ImageFilledRectangle($png,0,0,88,31,$bg);
把圖片填上白色
ImageString($png,6,11,2,"test",$tx);
在圖片上加上文字 "test"
6是字形大小
11和2是位置
11是X軸(由左至右),2是Y軸(由上至下)
ImageString() 可以使用數次
例如:
ImageString($png,3,11,2,"test1",$tx);
ImageString($png,3,11,17"test2",$tx);
就會出現:

Imagepng($png);
將圖形輸出至瀏覽器
ImageDestroy($png);
移除圖片
原始來源:http://www.pczonehk.com/view.php?type=homepage&cat=php&id=5
本帖由dc最後編輯於2002-08-15 18:29
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-08-15 18:28 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 10 篇) 音樂隨機選撥
<?
$anjara_list = array ("音樂檔1", "音樂檔2", "音樂檔3", "音樂檔4");
srand (mktime ());
$anjara_list_length = sizeof($anjara_list) + 0;
$anjara_index = (rand() % $anjara_list_length);
$anjara_gfx = $anjara_list[$anjara_index];
echo "<embed hidden src=URL/$anjara_gfx loop=-1 width=72 height=25></a>"
?>
音樂檔名稱及位址依你的情況修改。
作者:DragonX
出處:http://forum.martinx.idv.tw/thread.php?threadid=76&boardid=15&styleid=1&sid=68fd19aa6e8b16b17955818c0c4a6288
本帖由dc最後編輯於2002-08-26 16:21
Your mind to my mind,
your thought to my thought |
| 發表時間:2002-08-26 16:20 |
|
|
所有時間均為GMT+8, 現在是2026-02-11 01:33 分頁:[ 1 2 ] |
|