๒๒ พ.ย. ๒๕๕๐

เซ็งเป็ด

เซ็งเป็ด

ไม่เข้าใจ คำนี้ หมายความว่าอะไร ทราบแต่ว่าอาการมันเป็นอย่างไร วันนี้เขียนโค้ดที่ต้องเกี่ยวข้องกับ session

เกิดอาการ เซ็งเป็ด

ไม่รู้เป็นอะไรของมัน เมื่อใช้คำสั่ง session_start() แล้ว หน้าเพจมันดัน ดีฟอลต์ที่ภาษาไทย ทั้งที่ในไฟล์ php เราก็เซตเป็น utf-8 ฐานข้อมูล ก็ 8 อะไรๆ ก็แปด IE มันก็ยังทะลึ่ง เลือกที่ภาษาไทยอยู่นั่น เท่านั้นยังไม่พอ หน้าที่มันแสดงออกมา ดันขาวโพลน ซะงั้น ผู้หญิงขาว พอรับได้ แต่หน้าเว็บขาว ทั้งที่มันน่าจะมีอะไรแสดงมาบ้าง นี่สิ รับไม่ได้ (ว้อย...)

พอ กดปุ่ม F5 มันก็แสดงหน้าที่เราจะให้แสดงออกมานะ แต่มันไม่ใช่ อะกิ๊ฟ มันไม่ช่าย

คิดไม่ออกว่ามันเป็นเพราะอะไร และไม่เคยเจอด้วย

ไปหาตามเว็บฝรั่ง ดูว่าคุณๆเขาเคยเจอแบบนี้บ้างป่าว ไปเจอข้อความนี้เข้า


For those encoding their pages in UTF-8 but running into problems with BOM data (Byte Order Marks) being outputted before anything else - such as $_SESSION data - but wish to use UTF-8 encoding, and who do NOT wish to use UTF-8 No BOM encoding because the latter produces weird results when using foreign language accented characters, try the following :

- Save your document with UTF-8 No BOM encoding (on a mac, using BBEdit, this is normally found on the very bottom left corner of the window). This will produce a document that will not output BOM data.
- then, in your scripts, include the following:

header('Content-Type: text/html; charset=UTF-8');

before your call to session_start()

hope that helps someone.


[ design at ericcorriel dot com ]ให้เครดิตพี่เขาหน่อย


ในประโยคทั้งหมด แปลออกอยู่ท่อนเดียว

header('Content-Type: text/html; charset=UTF-8');
before your call to session_start()

ใส่ header('Content-Type: text/html; charset=UTF-8'); ไว้ก่อนเรียก session_start()
ส่วนที่เหลืออ่านไม่ออก

เห็นว่ามันพอมีเค้า ลองดู ช๊ะช้า หายวุ้ย อาการที่เคยเป็น หาย

แต่ก็ยัง งงๆ มันเป็นอะไรของมัน

เฮ่อ เซ็งเป็ด

ไม่มีความคิดเห็น: