- Dec 16 Thu 2021 14:15
-
[Laravel] Use static variables in Laravel
- Dec 14 Tue 2021 15:48
-
[PHP][轉] 幾行代碼輕鬆實現PHP文件打包下載zip
- Dec 01 Wed 2021 16:18
-
[dataTable][轉] How to Export Multiple Row Headers in jQuery Datatables?
最近遇到dataTable使用complex header匯出只會匯出最後一行header的問題
找到的方法是要手動修改buttons.html5.js內容
已經好幾年了不知道為何官方不修這個問題orz
修改方法如下:
找到的方法是要手動修改buttons.html5.js內容
已經好幾年了不知道為何官方不修這個問題orz
修改方法如下:
- Dec 01 Wed 2021 11:23
-
[PHP][轉] strpos — 查找字符串首次出现的位置
[php]strpos — 查找字符串首次出现的位置
官方範例1
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// 注意這裡使用的是 ===。簡單的 == 不能像我們期待的那樣工作,
// 因為 'a' 是第 0 位置上的(第一個)字符。
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
?>
官方範例2
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// 使用 !== 操作符。使用 != 不能像我們期待的那樣工作,
// 因為 'a' 的位置是 0。語句 (0 != false) 的結果是 false。
if ($pos !== false) {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
} else {
echo "The string '$findme' was not found in the string '$mystring'";
}
?>
官方範例3
<?php
// 忽視位置偏移量之前的字符進行查找
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, 不是 0
?>
官方範例1
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// 注意這裡使用的是 ===。簡單的 == 不能像我們期待的那樣工作,
// 因為 'a' 是第 0 位置上的(第一個)字符。
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
?>
官方範例2
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// 使用 !== 操作符。使用 != 不能像我們期待的那樣工作,
// 因為 'a' 的位置是 0。語句 (0 != false) 的結果是 false。
if ($pos !== false) {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
} else {
echo "The string '$findme' was not found in the string '$mystring'";
}
?>
官方範例3
<?php
// 忽視位置偏移量之前的字符進行查找
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, 不是 0
?>
- Nov 25 Thu 2021 18:10
-
[轉][PHP] PHP 等比例縮圖程式
這是一個不錯的PHP 縮圖程式,找到的時候好興奮說
使用上很方便,只要照著自己需求去設定就可以囉
我有刪除部分不需要的內容,如果像看原文最下面有轉貼網址。
兩個 function, 一個算比例要多少(getResizePercent)
另一個 function 依照比例將圖片縮小
縮到剛好符合預計縮小的其中一邊的尺寸(ImageResize).
使用上只要將這兩個 function 一起放進程式裡面
直接呼叫 ImageResize(), 把參數傳進去即可.
ImageResize function
使用上很方便,只要照著自己需求去設定就可以囉
我有刪除部分不需要的內容,如果像看原文最下面有轉貼網址。
兩個 function, 一個算比例要多少(getResizePercent)
另一個 function 依照比例將圖片縮小
縮到剛好符合預計縮小的其中一邊的尺寸(ImageResize).
使用上只要將這兩個 function 一起放進程式裡面
直接呼叫 ImageResize(), 把參數傳進去即可.
ImageResize function
- Nov 25 Thu 2021 18:07
-
[PHP][轉] PHP 刪除目錄和以下檔案
- Nov 24 Wed 2021 15:09
-
[PHP][轉] PHP Try Catch
注意:Laravel使用try catch要先use Exception;
否則會出現 Class 'App\Http\Controllers\Exception' not found 的 error msg
--
否則會出現 Class 'App\Http\Controllers\Exception' not found 的 error msg
--
- Nov 24 Wed 2021 10:54
-
[dataTable] drawCallback取得換頁後的該頁資料
"drawCallback": function( settings ) {
var api = this.api();
var data = api.rows( {page:'current'} ).data();
- Nov 24 Wed 2021 10:49
-
[jQuery] jquery選擇一個帶有冒號的ID
Q:
我正在爲一個站點編寫一個預先編寫的模塊,並且我需要定位一個ID爲test:two的元素。現在,這個元素有一個冒號,所以jquery大概可以理解地把'two'看作一個僞類。有什麼方法可以用jQuery來定位這個元素嗎?jquery選擇一個帶有冒號的ID
此外,更改ID是不可能的。相信我,如果我能的話。
我正在爲一個站點編寫一個預先編寫的模塊,並且我需要定位一個ID爲test:two的元素。現在,這個元素有一個冒號,所以jquery大概可以理解地把'two'看作一個僞類。有什麼方法可以用jQuery來定位這個元素嗎?jquery選擇一個帶有冒號的ID
此外,更改ID是不可能的。相信我,如果我能的話。
- Nov 24 Wed 2021 10:35
-
[PHP][轉] max_input_vars導致PHP Post 變量上限1000的解決方法
- Nov 11 Thu 2021 09:33
-
[PhpspreedSheet] 設定超鏈結 hyperlink 文字樣式(藍色&底線)
PhpspreedSheet建立hyperlink時,他不會像使用excel軟體編輯超連結時自動把文字加上藍色與底線,要自己加上style。
如下
$link_style_array = array(
'font' => array(
'color' => array('rgb' => '0000FF'),
'background-color' => array('rgb' => 'FFFFFF'),
'underline' => 'single'
)
);
$sheet->getStyle("A1")->applyFromArray($link_style_array);
如下
$link_style_array = array(
'font' => array(
'color' => array('rgb' => '0000FF'),
'background-color' => array('rgb' => 'FFFFFF'),
'underline' => 'single'
)
);
$sheet->getStyle("A1")->applyFromArray($link_style_array);
- Nov 10 Wed 2021 16:05
-
[PHP][轉] 如何在php中使用curl下載檔案?
如果頭設定為true,如何使用curl在php中下載檔案?我還可以得到檔名和副檔名嗎?
php程式碼示例:
curl_setopt ($ch, CURLOPT_HEADER, 1);
$fp = fopen($strFilePath, 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
php程式碼示例:
curl_setopt ($ch, CURLOPT_HEADER, 1);
$fp = fopen($strFilePath, 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);