 |
เรียนถามท่านผู้รู้ค่ะ คือดิฉันเขียนฟังก์ชั่น datethaiไว้แล้วจะเรียกใช้ฟังก์ชั่นยังไงค่ะ(เรียกแล้ว error) |
|
 |
|
|
 |
 |
|
เรียนถามท่านผู้รู้ค่ะ คือดิฉันเขียนฟังก์ชั่น datethaiไว้แล้วจะเรียกใช้ฟังก์ชั่นยังไงค่ะ(เรียกแล้ว error)
ฟังชั่น datethai ที่เขียนไว้ชื่อ funcdate.php
Code (PHP)
<?php
function DateThai($strDate) {
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear";
}
?>
และหน้า fview_report_workprogress_depart.php เรียกใช้งานเขียนcodeดังนี้
Code (PHP)
$startdate = $jobtype[$i][7];
include("function/funcdate.php");
function DateThai($startdate) {
echo $startdate;
ฟ้อง error
Fatal error: Cannot redeclare datethai() (previously declared in C:\AppServ\www\mydata\function\funcdate.php:2) in C:\AppServ\www\mydata\fview_report_workprogress_depart.php on line 118
รบกวนท่านผู้รู้ช่วยตอบด้วยนะค่ะ
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP
|
|
 |
 |
 |
 |
Date :
2011-03-08 11:06:08 |
By :
มือใหม่ |
View :
1076 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$startdate = $jobtype[$i][7];
include("function/funcdate.php");
echo DateThai($startdate) {
|
 |
 |
 |
 |
Date :
2011-03-08 11:15:52 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆนะค่ะ
คุณPlaKriM
|
 |
 |
 |
 |
Date :
2011-03-08 11:30:40 |
By :
มือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรียนถามต่ออีกนะค่ะ คือว่า
ค่าที่ผ่านเข้าไปในฟังก์ชั่น DateThai เป็น 0000-00-00
แล้วค่า return ออกมาเป็น 30 พ.ย.2542 ซึ่งเป็นค่าที่ไม่ถูก
และดิฉันอยากให้ return ค่าออกมาเป็น 00-00-0000
ต้องเขียนcode ยังไงค่ะ
รบกวนท่านผู้รู้ช่วยตอบด้วยนะค่ะ
|
 |
 |
 |
 |
Date :
2011-03-08 12:00:37 |
By :
มือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
function DateThai($strDate) {
if($strDate == '0000-00-00') return $strDate;
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear";
}
|
 |
 |
 |
 |
Date :
2011-03-08 12:08:52 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณPlaKriM มากๆนะค่ะที่ช่วยเหลือดิฉัน
|
 |
 |
 |
 |
Date :
2011-03-08 12:16:41 |
By :
มือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|