Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > Strict Standards: Non-static method Currency::bahtThai() should not be called statically in เกิดจากอะไรหรอคับ


[PHP] Strict Standards: Non-static method Currency::bahtThai() should not be called statically in เกิดจากอะไรหรอคับ

 
Topic : 107079



โพสกระทู้ ( 172 )
บทความ ( 0 )



สถานะออฟไลน์



Strict Standards: Non-static method Currency::bahtThai() should not be called statically in เกิดจากอะไรหรอคับ

Code (PHP)
001.class Currency {
002.  public function bahtEng($thb) {
003.   list($thb, $ths) = explode('.', $thb);
004.   $ths = substr($ths.'00', 0, 2);
005.   $thb = Currency::engFormat(intval($thb)).' Baht';
006.   if (intval($ths) > 0) {
007.    $thb .= ' and '.Currency::engFormat(intval($ths)).' Satang';
008.   }
009.   return $thb;
010.  }
011.  // ตัวเลขเป็นตัวหนังสือ (ไทย)
012.  public function bahtThai($thb) {
013.   @list($thb, $ths) = explode('.', $thb);
014.   $ths = substr($ths.'00', 0, 2);
015.   $thaiNum = array('', 'หนึ่ง', 'สอง', 'สาม', 'สี่', 'ห้า', 'หก', 'เจ็ด', 'แปด', 'เก้า');
016.   $unitBaht = array('บาท', 'สิบ', 'ร้อย', 'พัน', 'หมื่น', 'แสน', 'ล้าน', 'สิบ', 'ร้อย', 'พัน', 'หมื่น', 'แสน', 'ล้าน');
017.   $unitSatang = array('สตางค์', 'สิบ');
018.   $THB = '';
019.   $j = 0;
020.   for ($i = strlen($thb) - 1; $i >= 0; $i--, $j++) {
021.    $num = $thb[$i];
022.    $tnum = $thaiNum[$num];
023.    $unit = $unitBaht[$j];
024.    switch (true) {
025.     case $j == 0 && $num == 1 && strlen($thb) > 1:
026.      $tnum = 'เอ็ด';
027.      break;
028.     case $j == 1 && $num == 1:
029.      $tnum = '';
030.      break;
031.     case $j == 1 && $num == 2:
032.      $tnum = 'ยี่';
033.      break;
034.     case $j == 6 && $num == 1 && strlen($thb) > 7:
035.      $tnum = 'เอ็ด';
036.      break;
037.     case $j == 7 && $num == 1:
038.      $tnum = '';
039.      break;
040.     case $j == 7 && $num == 2:
041.      $tnum = 'ยี่';
042.      break;
043.     case $j != 0 && $j != 6 && $num == 0:
044.      $unit = '';
045.      break;
046.    }
047.    $S = $tnum.$unit;
048.    $THB = $S.$THB;
049.   }
050.   if ($ths == '00') {
051.    $THS = 'ถ้วน';
052.   } else {
053.    $j = 0;
054.    $THS = '';
055.    for ($i = strlen($ths) - 1; $i >= 0; $i--, $j++) {
056.     $num = $ths[$i];
057.     $tnum = $thaiNum[$num];
058.     $unit = $unitSatang[$j];
059.     switch (true) {
060.      case $j == 0 && $num == 1 && strlen($ths) > 1:
061.       $tnum = 'เอ็ด';
062.       break;
063.      case $j == 1 && $num == 1:
064.       $tnum = '';
065.       break;
066.      case $j == 1 && $num == 2:
067.       $tnum = 'ยี่';
068.       break;
069.      case $j != 0 && $j != 6 && $num == 0:
070.       $unit = '';
071.       break;
072.     }
073.     $S = $tnum.$unit;
074.     $THS = $S.$THS;
075.    }
076.   }
077.   return $THB.$THS;
078.  }
079.  // ตัวเลขเป็นตัวหนังสือ (eng)
080.  private function engFormat($number) {
081.   list($thb, $ths) = explode('.', $thb);
082.   $ths = substr($ths.'00', 0, 2);
083.   $max_size = pow(10, 18);
084.   if (!$number)
085.    return "zero";
086.   if (is_int($number) && $number < abs($max_size)) {
087.    switch ($number) {
088.     case $number < 0:
089.      $prefix = "negative";
090.      $suffix = Currency::engFormat(-1 * $number);
091.      $string = $prefix." ".$suffix;
092.      break;
093.     case 1:
094.      $string = "one";
095.      break;
096.     case 2:
097.      $string = "two";
098.      break;
099.     case 3:
100.      $string = "three";
101.      break;
102.     case 4:
103.      $string = "four";
104.      break;
105.     case 5:
106.      $string = "five";
107.      break;
108.     case 6:
109.      $string = "six";
110.      break;
111.     case 7:
112.      $string = "seven";
113.      break;
114.     case 8:
115.      $string = "eight";
116.      break;
117.     case 9:
118.      $string = "nine";
119.      break;
120.     case 10:
121.      $string = "ten";
122.      break;
123.     case 11:
124.      $string = "eleven";
125.      break;
126.     case 12:
127.      $string = "twelve";
128.      break;
129.     case 13:
130.      $string = "thirteen";
131.      break;
132.     case 15:
133.      $string = "fifteen";
134.      break;
135.     case $number < 20:
136.      $string = Currency::engFormat($number % 10);
137.      if ($number == 18) {
138.       $suffix = "een";
139.      } else {
140.       $suffix = "teen";
141.      }
142.      $string .= $suffix;
143.      break;
144.     case 20:
145.      $string = "twenty";
146.      break;
147.     case 30:
148.      $string = "thirty";
149.      break;
150.     case 40:
151.      $string = "forty";
152.      break;
153.     case 50:
154.      $string = "fifty";
155.      break;
156.     case 60:
157.      $string = "sixty";
158.      break;
159.     case 70:
160.      $string = "seventy";
161.      break;
162.     case 80:
163.      $string = "eighty";
164.      break;
165.     case 90:
166.      $string = "ninety";
167.      break;
168.     case $number < 100:
169.      $prefix = Currency::engFormat($number - $number % 10);
170.      $suffix = Currency::engFormat($number % 10);
171.      $string = $prefix."-".$suffix;
172.      break;
173.     case $number < pow(10, 3):
174.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 2))))." hundred";
175.      if ($number % pow(10, 2))
176.       $suffix = " and ".Currency::engFormat($number % pow(10, 2));
177.      $string = $prefix.$suffix;
178.      break;
179.     case $number < pow(10, 6):
180.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 3))))." thousand";
181.      if ($number % pow(10, 3))
182.       $suffix = Currency::engFormat($number % pow(10, 3));
183.      $string = $prefix." ".$suffix;
184.      break;
185.     case $number < pow(10, 9):
186.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 6))))." million";
187.      if ($number % pow(10, 6))
188.       $suffix = Currency::engFormat($number % pow(10, 6));
189.      $string = $prefix." ".$suffix;
190.      break;
191.     case $number < pow(10, 12):
192.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 9))))." billion";
193.      if ($number % pow(10, 9))
194.       $suffix = Currency::engFormat($number % pow(10, 9));
195.      $string = $prefix." ".$suffix;
196.      break;
197.     case $number < pow(10, 15):
198.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 12))))." trillion";
199.      if ($number % pow(10, 12))
200.       $suffix = Currency::engFormat($number % pow(10, 12));
201.      $string = $prefix." ".$suffix;
202.      break;
203.     case $number < pow(10, 18):
204.      $prefix = Currency::engFormat(intval(floor($number / pow(10, 15))))." quadrillion";
205.      if ($number % pow(10, 15))
206.       $suffix = Currency::engFormat($number % pow(10, 15));
207.      $string = $prefix." ".$suffix;
208.      break;
209.    }
210.   }
211.   return $string;
212.  }
213. }


Code (PHP)
1.$sum_discount1 = "250";
2.echo Currency::bahtThai($sum_discount1);




Tag : PHP

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-20 09:45:16 By : maojunghi View : 864 Reply : 2
 

 

No. 1



โพสกระทู้ ( 437 )
บทความ ( 3 )



สถานะออฟไลน์


Code (PHP)
1.public function bahtThai($thb)


ไม่ใช่ static มันเลย warning ถ้าอยากใช้แบบ static เปลี่ยนเป็น

Code (PHP)
1.public static function bahtThai($thb)



ไม่งั้นก็เรียกใช้

Code (PHP)
1.$currency = New Currentcy;
2. 
3.$currency->bahtThai($thb);

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-20 10:06:49 By : randOmizE
 

 

No. 2



โพสกระทู้ ( 172 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-20 11:00:00 By : maojunghi
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Strict Standards: Non-static method Currency::bahtThai() should not be called statically in เกิดจากอะไรหรอคับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่