2013年8月29日 星期四
PHP Mysql 顯示textarea換行顯示
方法1:
使用 str_replace 函數將 ASCII 13 與 10 置換為 <BR>
$demo_text = str_replace( chr(13).chr(10), "<br>", $demo_text );
方法2:
nl2br($row_rsData['content']);
參考網址
http://jikky.pixnet.net/blog/post/18623999-php%E7%B6%B2%E9%A0%81%E4%B8%AD,-%E8%87%AA%E5%8B%95%E6%9B%BF%E6%8F%9B%E7%B4%94%E6%96%87%E5%AD%97%E5%85%A7%E5%AE%B9%E6%8F%9B%E8%A1%8C%E9%A1%AF%E7%A4%BA%E7%9A%84%E6%96%B9
http://chensh.loxa.edu.tw/php/X_8.php
http://www.w3school.com.cn/php/func_string_str_replace.asp
2013年8月26日 星期一
清單
ul{
list-style-type:none;
padding-left: 20px;
line-height: 18px;
padding-right: 15px;
}
ul a{
text-decoration: none;
color: #D2DDFF;
}
li{
background-image: url(../img/news_icon_04.png);
background-repeat: no-repeat;
background-position:0 0.5em;
padding-left:15px;
}
.font001{/*資料title*/
font-family: "新細明體";
font-size: 12px;
color: #D2DDFF;
width: 320px;
word-wrap:break-word; /* 自動換行*/
overflow:hidden;
display: table-cell; /*區塊顯示─表格-儲存格*/
background-color: #996666;
}
.font002{/*日期*/
font-size: 10px;
color: #B6CDFF;
width: 60px;
text-align: right;
background-color: #006666;
display: table-cell; /*區塊顯示─表格-儲存格*/
}
<ul id="vertical-ticker">
<li>
<span class="font001"><a href="#">A01</a></span>
<span class="font002">A02</span>
</li>
<li>
<span class="font001"><a href="#">B01</a></span>
<span class="font002">B02</span>
</li>
</ul>
ps.ul會有預設邊框
顯示方式
- XXXXXXXXXXXXXX
- XXXXXXXXXXXXXX
參考資料
http://foreverahow.blogspot.tw/2008/09/css.html
2013年8月25日 星期日
PHP readfile
- <php.ini> include path指定路徑
- $line = file( 'XX.htm'檔案路徑 ) [array]
- foreach( $line as $num => $line ) $num行數
- htmlspecialchars($line) 反斜線特殊字元
- $content = file_get_contents('XXX.htm檔案路徑')
- strip_tags($content) 去除標籤
- 寫入檔 $filesize = file_put_contents("xx.txt檔案路徑", $content字串, [狀態指標1|狀態指標2])
- [狀態指標]
- [1] FILE_USE_INCLUDE_PATH 指定路徑開啟指定檔案
- FILE_APPEND 將字串寫入檔案內容後方
- LOCK_EX 寫入時先鎖定檔案,防止同時被寫入
- read and output
- is_readable(檔案路徑)
- readline(檔案路徑, [ ])
- file open
- fopen(檔案路徑, 開啟模式 [, ])
- 檔案路徑
- 使用$_SERVER['DOCUMENT_ROOT'](在本機記得將"/"改為"\\",直接上線的就不用)
- C:\\htdocs\\...
- http://www.abc.com/..
- 開啟模式
- r :開啟唯讀檔
- r+:開啟為可讀寫檔
- w:寫入檔。先清空再寫入。檔不在則新增
- w+:讀寫檔。先清空再寫入。檔不在則新增
- a:寫入檔。寫在檔案尾端。檔不在則新增
- a+:讀寫檔。寫在檔案尾端。檔不在則新增
- fclose(資源) return True/Flase
- flock(資源$file, 鎖定方式 [,])
- 鎖定方式
- LOCK_SH 唯讀
- LOCK_EX 獨占,寫入
- LOCK_UN 解除唯讀
- LOCK_NB 排它性鎖定 (若已被鎖,no wait and pass)
- fputs(資源, 字串)
- fwrite(資源, 字串)
- fgetc(資源) 每讀一字元回傳,到底回傳false
- fgets(資源) 每讀一行資料回傳,到底回傳false
- fpassthru(資源) 讀取並顯示在頁面,自動關閉
- stream_get_contents(資源) 讀取並顯示在頁面,需用fclose( )關閉
- fread(資源, 檔案大小) 可讀取二進位檔,ex:圖檔
- fopen(檔案, "rb")
- echo fread(檔案, filesize(檔案));
- fclose(檔案)
- ftell(資源) return 目前指標位置
- feof(資源) 是否到達檔案底部 T/F
- rewind(資源) 檔案關閉前,指標移至開啟的地方(開頭)
- fssek(資源, 移動值, [起始位置])
- 設定值
- SEEK_SET 檔案開始,預設
- SEEK_CUR 現在位置
- SEEK_END 檔案底部
readfile( );
$logs_file = fopen($_SERVER['DOCUMENT_ROOT']."/support/logs.txt","a");
fwrite($logs_file, "寫入檔案。");
fclose($logs_file);
檔案是否存在
http://www.hkcode.com/programming/601
$logs_file = fopen($_SERVER['DOCUMENT_ROOT']."/support/logs.txt","a");
fwrite($logs_file, "寫入檔案。");
fclose($logs_file);
檔案是否存在
http://www.hkcode.com/programming/601
2013年8月24日 星期六
PHP - upload file
file_uploads = On
upload_tmp_dir = "C:\Windows\Temp" [ = "tmp" Linux]
upload_tmp_dir = "C:\Windows\Temp" [ = "tmp" Linux]
- <form action="接收檔.php" method="post" enctype="multipart/form-data"> [傳送資料的編碼方式]
- 單一/多檔 上傳
- <input type="file" name="fileUpload">
- <input type="file" name="fileUpload[ ]">
- 暫存檔資訊
- $_FILES["欄位名稱"]["tmp_name"] 取得暫存檔名稱
- $_FILES["欄位名稱"]["name"] 取得原本名稱
- $_FILES["欄位名稱"]["type"] 取得檔案類型[text/plain]、[image/pjpeg]
- $_FILES["欄位名稱"]["size"] 取得檔案大小
- $_FILES["欄位名稱"]["error"] 取得錯誤碼
- [ 0 ]UPLOAD_ERR_OK 上傳成功
- [ 1 ]UPLOAD_ERR_INI_SIZE 檔案大於<php.ini>中設定upload_max_filesize的最大上傳檔案大小
- [ 2 ]UPLOAD_ERR_FROM_SIZE 檔案大於表單(form)能傳送的大小MAX_FILE-SIZE
- [ 3 ]UPLOAD_ERR_PARTIAL 只有部分檔案被上傳
- [ 4 ]UPLOAD_ERR_NO_FILE 檔案沒有被上傳
- [ 5 ]UPLOAD_ERR_NO_TMP_DIR 沒有設定/找不到 暫存檔案夾
- [ 6 ]UPLOAD_ERR_CANT_WRITE 檔案寫入磁碟失敗
- move_upload_file( 暫存檔名稱, 目的路徑及檔名 ) "./".FILES[ ][ ]
- 多檔 二維陣列 $_FILES["欄位名稱"]["tmp_name"][$i]
- 一維:$_FILES["欄位名稱"]["tmp_name"]
- 二維:[$i]
- 注意表單 form 需要加上 enctype="multipart/form-data" 代表你要上傳檔案
- utf-8 編碼網頁無法在 big5 系統正確處理中文檔名,原因在於 move_uploaded_file() 不能處理 utf-8 中文編碼,需利用 iconv() 函數作轉碼,解決方法如下:
- 請將
- move_uploaded_file($_FILES['myfile']['tmp_name'], $uploadfile)
- 改為
- move_uploaded_file($_FILES['myfile']['tmp_name'], iconv("utf-8", "big5", $uploadfile))
參考資料:
2013年8月19日 星期一
CSS 固定欄寬 自動斷行
.table01{
width:650px;
table-layout:fixed; /*固定欄寬*/
word-wrap:break-word;
overflow:hidden;
}
/*欄位寬也要設定*/
.table th{
width:200px;
}
.table td{
450px;
}
---------------------------------------------------
.div01{
width:650px;
word-wrap:break-word;
overflow:hidden;
}
1. word-wrap: 單字換行
2. word-break: 斷字的方法,用於長字串
參考資料:
http://www.dugukeji.com/mb/divcssjiaocheng/16639.html
http://hihicharles.blogspot.tw/2010/12/css-word-wrap.html
width:650px;
table-layout:fixed; /*固定欄寬*/
word-wrap:break-word;
overflow:hidden;
}
/*欄位寬也要設定*/
.table th{
width:200px;
}
.table td{
450px;
}
---------------------------------------------------
.div01{
width:650px;
word-wrap:break-word;
overflow:hidden;
}
1. word-wrap: 單字換行
2. word-break: 斷字的方法,用於長字串
參考資料:
http://www.dugukeji.com/mb/divcssjiaocheng/16639.html
http://hihicharles.blogspot.tw/2010/12/css-word-wrap.html
2013年8月17日 星期六
Xampp - Apache
Method :
1.暫時關閉IIS
2.apache\conf下的“httpd.conf”文件来修改XAMPP使用的port
●http://localhost/phpmyadmin/ 如果修權限修改
需在C:\xampplite\phpMyAdmin\config.inc.php 修改
參考網址:
http://www.97world.com/archives/2270
http://elaine-iic.blogspot.tw/2013/03/iis7apache.html 共存
Windows7上IIS7.5與XAMPP 的port冲突的解决方法:http://www.duote.com/tech/4/11179.html
Xampp中Apache無法啟動的解决方法:http://www.itstudy.cn/www/article/article.asp?id=7
Win7 XAMPP apache無法啟動的问题:http://www.cnblogs.com/likwo/archive/2011/08/01/2123937.html
1.暫時關閉IIS
2.apache\conf下的“httpd.conf”文件来修改XAMPP使用的port
●http://localhost/phpmyadmin/ 如果修權限修改
需在C:\xampplite\phpMyAdmin\config.inc.php 修改
參考網址:
http://www.97world.com/archives/2270
http://elaine-iic.blogspot.tw/2013/03/iis7apache.html 共存
Windows7上IIS7.5與XAMPP 的port冲突的解决方法:http://www.duote.com/tech/4/11179.html
Xampp中Apache無法啟動的解决方法:http://www.itstudy.cn/www/article/article.asp?id=7
Win7 XAMPP apache無法啟動的问题:http://www.cnblogs.com/likwo/archive/2011/08/01/2123937.html
訂閱:
意見 (Atom)