|
 |
|
กำลังคิดจะทำเว้บบอร์ดมาแจก เอาไว้ให้ศึกษาโค้ดเล่นๆ นะ ผมเห็นสมาชิกชอบถามเกี่ยวกับโค้ด |
|
 |
|
|
 |
 |
|
ลืมบอก เปลียนภาษาได้ด้วยนะ แต่ตอนนี้ มีแค่ภาษาไทยภาษาเดียว เพราะขี้เกียจ 
|
 |
 |
 |
 |
Date :
2009-07-22 14:44:58 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อะขอบคุณนะคะที่ นำโค๊ดดีดีมาให้
ถ้าทำเว็บ 2 ภาษา พี่ทำยังไงคะ
|
 |
 |
 |
 |
Date :
2009-07-22 14:54:17 |
By :
SG14 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้การ include ไฟล์ครับ
แล้วจำค่าโดยใช้ $_COOKIE ของผู้ใช้
แบบเบี้องต้นก่อน
แต่ ถ้าเวอร์ชั่นสูงๆ แล้ว
ผมจะเก็บในแดต้าเบสแทน เพื่อ ให้สามารถ แก้ไข โดยผ่านหน้าเว็บได้เลย
|
 |
 |
 |
 |
Date :
2009-07-22 15:03:35 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือในเว็บจะมีหน้า home product webboard contact us
ในหน้า webboard แล้วก็พวกล๊อคอินสมัครสมาชิก เราไม่ให้มันเปลี่ยนภาษาได้
แล้วลิงค์เราทำมาจากรูปภาพนะคะ
ตอนนี้ทำเทมเพจไว้สองอัน อันนึงไทย อันนึงอังกฤษ
ถ้าในกรณีแบบนี้ ควรจะทำแบบเดิมดี(วิธีสร้างแบบมีสองไฟล์แล้วทำลิงค์เอา เช่น home.phpหน้าอังกฤษ homeT.phpหน้าไทย)
หรือว่าเป็นโค๊ดอย่างพี่ว่าดีคะ(แต่ไม่เคยทำเลย)
|
 |
 |
 |
 |
Date :
2009-07-22 15:09:00 |
By :
SG14 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่างโค้ดครับ
Code (PHP)
<?php
/**
* @author Marosdee
* @copyright 2009
*/
$CONFIG['cookie_prefix'] = 'cc_';
$CONFIG['language_all'] = array('thai', 'eng');
$CONFIG['language_used'] = 'thai';
define('ROOT_PATH', 'c:/AppServ/www/webboard/');
define('LANG_DIR','language/');
//เช็คว่ามีคุกกี้ในเครื่องผุ้ใช้หรือเปล่า
if ( isset($_COOKIE[$CONFIG['cookie_prefix'] . 'lang']) )
{
//เช็คว่า ค่าในคุกกี้ มีอยู่ใน array จิง ป้องกันเรียกไฟล์ที่ไม่มีอยู่จิง
if ( in_array($_COOKIE[$CONFIG['cookie_prefix'] . 'lang'], $CONFIG['language_all']) )
{
//ใส่ค่าให้ตัวแปร
$CONFIG['language_used'] = $_COOKIE[$CONFIG['cookie_prefix'] . 'lang'];
}
}
//เช็คค่าว่า มีตัวแปร GET lang มาหรือเปล่า ในกรณีนี้ ผุ้ใช้ ทำการเปลียนภาษามานะครับ
if ( isset($_GET['lang']) )
{
//เช็คว่า ค่ามีอยู่ใน array จิง ป้องกันเรียกไฟล์ที่ไม่มีอยู่จิง
if ( in_array($_GET['lang'], $CONFIG['language_all']) )
{
//ใส่ค่าให้ตัวแปร
$CONFIG['language_used'] = $_GET['lang'];
setcookie($CONFIG['cookie_prefix'] . 'lang', $_GET['lang'], time() * 60 * 60 * 24 * 365);
}
}
//เรียกไฟล์ภาษา
require_once ROOT_PATH . LANG_DIR . $CONFIG['language_used'] . '/global.php';
?>
ตัวอย่างไฟล์ภาษา global.php
Code (PHP)
<?php
$LANG = array();
$LANG['home_page'] = 'หน้าแรก';
$LANG['cat_name'] = 'ชื่อหมวดหมู่';
$LANG['total_reply'] = 'จำนวนหัวข้อ';
$LANG['total_topic'] = 'จำนวนคำตอบ';
$LANG['last_topic_title'] = 'หัวข้อล่าสุด';
$LANG['webboard'] = 'เว็บบอร์ด';
$LANG['webboard_home'] = 'หน้าแรกเว็บบอร์ด';
$LANG['topic_title'] = 'ชื่อหัวข้อ';
$LANG['topic_postername'] = 'โพสท์โดย';
$LANG['topic_datetime'] = 'เมื่อ';
$LANG['topic_reply_count'] = 'ตอบ';
$LANG['topic_lastposter'] = 'ตอบล่าสุด';
$LANG['post_new_topic'] = 'ตั้งหัวข้อใหม่';
$LANG['topic_not_found'] = 'ไม่พบหัวข้อ';
$LANG['submit_new_topic'] = 'ตั้งหัวข้อใหม่';
$LANG['reset_new_topic'] = 'ล้าง';
?>
|
 |
 |
 |
 |
Date :
2009-07-22 15:16:12 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แน่ะนำ ให้ทำไฟล์แยกภาษา แล้ว include เอานะ
อ้อ แล้วแต่ถนัดดีกว่า เอิ้กๆ 
|
 |
 |
 |
 |
Date :
2009-07-22 15:17:44 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอรับโค๊ด zip มาให้ด้วย 
|
 |
 |
 |
 |
Date :
2009-07-22 15:18:44 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอรับสิ่งดีๆ จากคุณดุนยาครับ 
|
 |
 |
 |
 |
Date :
2009-07-22 15:35:23 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอ เหมือนกันครับ
|
 |
 |
 |
 |
Date :
2009-07-22 15:43:10 |
By :
spybnc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอให้ถึงเวอร์ชั่น 1.0 ก่อนนะ เดวมาแจก 555+
|
 |
 |
 |
 |
Date :
2009-07-22 15:48:03 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นั้นไง เห็นหายเงียบไปนานออกมาทีมีของฝากมาด้วย สุดยอดจริงๆ
ถามเพ่ๆทุกท่านนะคับ จะทำยังไงให้จำคำสั่ง php ได้อ่ะคับ ผมซื้อหนังสือมาอ่าน
โค้ดบ้างตัวที่เจอบ่อย ก็จะจำได้ แต่โค้ดบ้างตัวไม่ค่อยได้ใช้งานพอกับมาใช้งานกับจำไม่ได้ต้องมาเปิดหนังสือเหมือนเดิม แต่ถ้ามีคนสอนชี้แนวทางตรงนี้จำได้เป็นอย่างดีเลยคับ เพ่มีเคล็ดลับในการทำความเข้าใจกับ php กันอย่างไรคับ
step แต่ละคนอ่ะคับ
ขอบคุณมากคับ
|
 |
 |
 |
 |
Date :
2009-07-22 16:05:59 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเองก็ไม่รู้หมดครับ งูๆปลาๆไปวันๆ คอยจำทีละนิดๆ อันไหนที่จำแม่นคืออันที่เคยติด Bug ถ้ามีคนมาบอก หรือแก้ได้ก็จะจำจนตายอ่ะครับ  
|
 |
 |
 |
 |
Date :
2009-07-23 14:51:53 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จำอย่างเดียวไม่เท่าไรอ่ะครับแต่การทำความเข้าใจนี้ จิ ถ้าไม่มีคนอธิบายคงลำบาก หุหุหุหุ เหมือนโค้ดที่เพ่
ดุนยาให้มา อ่ะครับ จำได้ขึ้นใจ และทำความเข้าใจเป็นอย่างนี้เพราะว่าเพ่ เค้าอธิบายสะขนาดนั้น 
|
 |
 |
 |
 |
Date :
2009-07-23 15:27:22 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สวยเรียบง่ายดีครับ
|
 |
 |
 |
 |
Date :
2009-07-24 19:13:18 |
By :
pun05 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สุดยอดเลยครับ
|
 |
 |
 |
 |
Date :
2009-07-24 22:57:51 |
By :
newborn123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากคับ
Code (PHP)
<?php
echo"xx";
?>
|
 |
 |
 |
 |
Date :
2009-07-25 00:22:36 |
By :
bopenyang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|