發表文章

目前顯示的是有「程式語法紀錄」標籤的文章

bootstrap radio + card 樣式

html                         <div class="col-12 col-md-4">                             <label class="card-input" style="width:100%;">                                 <input type="radio" name="product" class="card-input-element" />                                 <div class="card card-input p-3">                                     <h5 class="card-title">標題</h5>                                     <div class="card-text">                   ...

laravel語法紀錄

再model更改時間格式:   use DateTimeInterface;          protected function serializeDate(DateTimeInterface $date)     {         return $date->format('Y-m-d H:i:s');     }

linux + git 順序語法

安裝 sudo yum install git-all clone git clone {github的檔案網址} 拉下來 git pull 拉不下來可以用下面這個 先拉在推 git pull --rebase linux使用ssh連線 1. 指令 : ssh-keygen 1.1 命名為 id_rsa (可以選擇檔案路徑) 1.2 設定密碼 1.3指令結束後 會出現兩個檔案 id_rsa 和 id_rsa.pub 2. 指令 : cat id_rsa.pub 2.1 將上面指令的結果貼到 github 2.1 設定位置 : Github 點頭像-> Settings -> Personal settings -> SSH and GPG keys 3. 指令 : eval $(ssh-agent -s)  3.1 指令 : ssh-add id_rsa 3.2 指令 ls -al ~/.ssh (查看是否有啟用)

資料庫

設定自動id的值  alter table table_name AUTO_INCREMENT=n 備份資料庫 mysqldump -h 127.0.0.1 -u thespbase -p thespbase > /home/wwwroot/www.thespbase.com/backup.sql;

composer/npm

composer更新 先上網去下載composer 在打下面指令 composer self-update --clean-backups composer更新 composer dump-autoload npm更新 npm rebuild node-sass

QRCODE

QRCODE echo '<img src="https://chart.googleapis.com/chart?cht=qr&chl=https://www.doitofficial.com/&chs=300x300"/>';

JS語法紀錄

 ajax 上傳csrf headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, jquery AJAX $.ajax({     url: 'service_update.php7',     data: {         store_issue_id: id,         type:'delete'     },     type: 'post',     success: function(data){         location.reload();     },     error:function(data) {         console.log(data);     } }); 取得某個日期的下一個日期 function getNextDate(date,day) {       var dd = new Date(date);       dd.setDate(dd.getDate() + day);       var y = dd.getFullYear();       var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;       var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();       return y + m + d; }; getNextDate("2018-09-27",10)

linux 指令紀錄

  切換最高權限 : sudo -s 刪除檔案或目錄 : rm -f 檔案或目錄: 強制刪除 rm -i 檔案或目錄: 刪除前會先詢問使用者 rm -r 檔案或目錄: 將檔案或目錄底下的所有檔案與子目錄一起刪除 顯示路由表  : route顯示路由表 安裝軟體 : yum install  重開機 reboot 列出打出過的指令 history 查看自己來源位置 who 列出目錄 ls  列出基本目錄 ls -l   列出詳細目錄資訊(權限/修改日期/擁有者) ls -a   列出目錄所有檔案(包含以  . 開頭的檔案) 移動所在地 cd  cd ~   回到使用者根目錄 顯示目前所在地 pwd  資料轉移操作指令   locate   查詢資料位置 zip  壓縮 unzip  解壓縮 mv business.zip(檔案) /home/test/(目的地)   移動檔案 mv test.zip(舊名字) new_test.zip(新名字) 複製  cp -r /ect/ /temp   複製資料夾 cp -a /ect/ /temp  複製資料夾和權限 找檔案 find . index.html   點是目前的資料夾 開始往裡面找 find . -iname *index*  -i 是檔案不是資料夾 find . -iname index.php 調整權限 chmod 754 testfile.txt 7 = 4 (讀) + 2 (寫) + 1 (執行) 5 = 4 (讀) + 1 (執行) 4 = 4 (讀) # 將既有帳號加入指定群組 usermod --append --groups YOUR_GROUP1,YOUR_GROUP2 YOUR_ACCOUNT

ajax上傳檔案紀錄

  如果是php表單要上傳物件只需要在form裡面加上enctype="multipart/form-data然後使用input type="file"就能吧檔案陣列中的五個屬性值一起上傳透過$_FILES["file"]來接收變數,然後使用php的製作圖檔或是檔案上傳程式來做後續處理,但如果是ajax表單是沒有form可以使用的,必須透過js取值然後用ajax來處理,好朋友一定認為這樣就能取到type="file"的值了。 var $upfile= $('input[name=file]').val(); 抱歉這樣只能抓到檔案路徑,檔案屬性是抓不到的,所以即使變數送出去也無法建立檔案,用js要抓取檔案屬性的方法必須使用FormData物件才行,請看以下說明: //html結構 <input class="form-control" id="blockimg" type="file" > <button id="upload">Upload</button> //$.ajax  $('#upload').on('click', function() {     var file_data = $('#blockimg').prop('files')[0];   //取得上傳檔案屬性     var form_data = new FormData();  //建構new FormData()     form_data.append('file', file_data);  //吧物件加到file後面                                    $.ajax({                 url: 'upload.php',             ...

php語法紀錄

  擷取某個符號以前的字串 substr ( $string , 0 , strpos ( $string , "T" ) ) ; 取得某個符號後的字串 $string_example = 'http://pjchender.blogspot.tw/2015/06/hyread.html' ; echo strrchr ( $string_example , "/" ) // 從尾巴開始搜尋'/'這個符號 // 輸出結果/hyread.html echo substr ( strrchr ( $string_example , "/" ) , 1 ) ; // 去除掉'/'這個符號,所以從第一個字元開始擷取到最後 // 輸出結果hyread.html addslashes 函數 的功能是替字串的特殊字符增加反斜線效果,會有這樣的需求主要在於部份的特殊符號會造成資料庫的錯誤或資料被竊取 addslashes ( $string ) ; 現在時間 date ( "Y-m-d H:i:s" ) date("Y/m/d H:i",strtotime($taiwan['modifydate']));更改時間格式 開啟錯誤提示 error_reporting ( E_ALL & ~ E_NOTICE ) ; ini_set ( 'display_errors' , 1 ) ; 二維陣列排序 //後方的 > 可以改為 < usort ( 二維陣列 , function ( $a , $b ) { $al = $a [ 'sort' ] ; $bl = $b [ 'sort' ] ; if ( $al == $bl ) return 0 ; return ( $al < $bl ) ? - 1 : 1 ; } ) ; 二維陣列排序兩次 usort ( $data [ 'all' ] , function ( $a ...