<?php $baseUrl = new Zend_View_Helper_BaseUrl(); $url = "http://{$_SERVER["HTTP_HOST"]}{$baseUrl->baseUrl("student/management")}"; $MAIL = new Zend_Mail('utf-8'); $message = "親愛的同學 您好:<br><br> 您的狀態已經做了更新,您可以上系統做查看。<br> 連結:<a href='".$url."'>點我</a> 若無反應請自行複製下方連結貼於網址:".$url."<br/> 本信為系統寄發,請勿直接回應本信。<br>"; // $MAIL->addTo($this->stuser->email); $MAIL->addTo('test@gmail.com'); $MAIL->setSubject('測試系統【狀態更新通知信】'); $MAIL->setBodyHtml($message,'utf-8', Zend_Mime::ENCODING_BASE64); $MAIL->setFrom($this->systememail, "提示系統"); $MAIL->Send(); ?>
目前分類:php (9)
- Jun 08 Thu 2017 11:23
php sendemail與夾帶連結
- Apr 20 Thu 2017 09:40
PHP 取得目前網址 轉自wibibi網頁設計教學百科
$_SERVER['HTTP_HOST']
$_SERVER['REQUEST_URI']
$_SERVER['PHP_SELF']
$_SERVER['QUERY_STRING']
假設我們的網址是 http://www.wibibi.com/test.php?tid=333
則以上 $_SERVER 分別顯示結果會是
echo $_SERVER['HTTP_HOST']; //顯示 www.wibibi.com
echo $_SERVER['REQUEST_URI']; //顯示 /test.php?tid=222
echo $_SERVER['PHP_SELF']; //顯示 /test.php
echo $_SERVER['QUERY_STRING']; //顯示 tid=222
透過這幾個 $_SERVER,我們已經取得了網址的各個部分,接著就是把網址給組合起來
echo $URL;
轉自wibibi網頁設計教學百科(http://www.wibibi.com/info.php?tid=85)
- Apr 05 Wed 2017 01:45
ajax傳送form array[],php取得 / send form using ajax with array[] form data (php)
<form id="insertform" name="insertform" > 略 <?php if( $this->lang ){ foreach($this->lang as $lang){ ?> <label class="checkbox-inline"> <input type="checkbox" name="lang[<?php echo $lang['公告語系ID']?>]" /><?php echo $lang['名稱'];?> </label> <?php } } ?> 略 <label><?php echo $lang['名稱']?>公告標題</label> <input name="title[<?php echo $lang['公告語系ID']?>]" type="text" class="form-control" > 略 <button onclick="insert()" class="btn btn-warning btn-block" >送出</button> </form>
<script> function insert() { event.preventDefault(); //使form按下按鈕後不會自行刷新 var formData = $('#insertform').serialize(); $.ajax({ type: 'POST', dataType: "json", data:{ 'formData':formData, 'act':'insert' }, success: function (data) { if(data.result) { // 成功時彈出modal,自動刷新 var modal = $('#succModal') $('.modal-title', modal).html(data.detail+',5秒後自動重整,若無自動跳頁<a style="cursor: pointer;" onClick="location.reload()">請點我跳頁</a>') modal.modal({ backdrop: 'static', keyboard: false }).on('click', 'button.close[type="button"]', function() { location.reload(); }).on('shown.bs.modal', function() { setTimeout(function() { location.reload(); }, 5000) }) } else { $('#alerttext').text(data.detail+","+data.debug.message) $('#inserterror').show() } }, error: function(xhr, ajaxOptions, thrownError){ alert(xhr.status); alert(thrownError); } }); } </script>
<?php
parse_str($this->getRequest()->getParam('formData'), $formData);
$starttime=$formData['starttime']; //一般之時間欄位
foreach($lang["data"] as $lang){
if($formData['lang'][$lang['公告語系ID']]=='on'){
print($formData['title'][$lang['公告語系ID']]);
}
}
?>
- Dec 15 Thu 2016 11:42
if 條件進階用法
<?php
if($data['認列等級']==""){
echo "無認列";
}else{
echo $data['認列等級'];
}
?>
---↓--↓-進-↓--↓-階-↓--↓--↓---
<?php
echo ($data['認列等級'] =="") ? "無認列" : $data['認列等級']
?>
- Dec 09 Fri 2016 23:02
PHP array 以值取得KEY
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
資料來源:http://php.net/manual/en/function.array-search.php
- Nov 25 Fri 2016 09:56
php foreach的另一種方式
<?php foreach($this->edulictypes as $edulictype): ?>
<option><?php echo $edulictype["名稱"]?></option>
<?php endforeach ?>
<?php foreach($this->edudb_types as $d){ ?>
<option><?php echo $d['category']; ?></option>
<?php } ?>
- Oct 17 Mon 2016 22:37
php 取得是否有檔案
protected $dir= 'C:/AppServ/www/專案/public/power/upload';
protected $url= '../upload/';
給予路徑與檔案要存放位置
select陣列拿出資料將每一筆有無圖片狀況帶入
$r = $result['rows'];
//取出證照圖片有無狀態
$count = count($r);
for($i=0;$i<$count;$i++){
$r[$i]['圖片狀態']=0;
if(file_exists($this->dir.'/'.$this->user->stuid.'.jpg')){
$r[$i]['圖片狀態']=1;
}
}
$this->view->url =$this->url;
$this->view->data = $r;
- Apr 15 Fri 2016 16:20
zend framework 方法不要依名稱跳頁//強制轉跳
zend framework 方法不要依名稱跳頁
$this->_helper->viewRenderer->setNoRender(true);
$this->view->layout()->disableLayout();
強制轉跳頁面
$this->_redirect('power/student/studentindex');
- Mar 23 Wed 2016 14:42
php時間的比較 / php comparetime
<?php $that_time = strtotime($bb2['created_date']); $this_time = mktime(); $diff = ($that_time - $this_time)/ (60*60*24); //計算日期差 / Calculate the date difference // $diff = ($that_time - $this_time); //計算秒數差 / Calculate the difference in seconds // $diff = ($that_time - $this_time)/ (60) ; //計算分鐘差 / Calculate the minute difference // $diff = ($that_time - $this_time)/ (60*60); //計算小時差 / Calculate the hour difference if ($diff>=-2){ // 當時間大於2天 / When the time is greater than 2 days ?> <span class="badge pull-right">New</span> <?php } ?>