flag
Mon. - Fri. 09:00 - 17:30

Blog Details

การรับตัวแปรจากฟอร์ม ส่งค่าไปยังไฟล์ PHP

การรับตัวแปรจากฟอร์ม ส่งค่าไปยังไฟล์ PHP

Share:

Howto ที่ไกล้เคียง

php ใช้ json_encode กับข้อมูลภาษาไทยแล้วไม่ขึ้นภาษาไทยแก้ไขอย่างไร

ให้เพิ่มตัวแปรตามนี้ครับ

json_encode($array, JSON_UNESCAPED_UNICODE);

https://github.com/moxiecode/plupload

$txt = 'ทดสอบ';
$txt = iconv( mb_detect_encoding($txt), 'Windows-874', $txt);

///////////

mb_detect_encoding($txt) // return encodeing

เรียกใช้คำสั่งง่ายๆด้วย

echo strip_tags($text);

กรณีที่ต้องการเปิดยอมรับ tags ที่ไม่ต้องการให้ลบก็เรียกใช้แบบนี้

function wget($address,$filename)
{
  file_put_contents($filename,file_get_contents($address));
}

เรียกใช้งานแบบนี้

wget(URL, FileName);

 

Class สำหรับ wget

https://gist.github.com/alash3al/aafe8ffa0a6ca12eb35f

$number = -10;
echo abs( $number );

$date=date_create("2013-03-15");
echo date_format($date,"Y/m/d H:i:s");

รูปแบบการนำไปใช้งานคือ

date('jS F Y')

อ่านคู่มือเต็มๆตามลิ้งค์ https://www.php.net/manual/en/function.date.php

$filename = 'Training-All';
header('Content-Encoding: utf-8');
header("Content-Type: text/xls; charset=utf-8");
header("Content-Transfer-Encoding: binary");
header("Content-Type: application/xls");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Content-Type: application/force-download");
header("Pragma: no-cache");
header("Expires: 0");

// กรณีที่ต้องการทำให้เป็นภาษาไทยให้ใส่ echo นี้ไว้ก่อน text
echo "xEFxBBxBF";
 
ถ้าเป็น xls จะต้องมี header meta ของ html แล้วก็ใช้งานโครงสร้าง table ได้เลย
แต่ถ้าเป็น csv แบ่งตารางด้วย , และจัดการบรรทัดด้วย แบ็คแสลทเอ็น
 
Register

Aosoft.co.th

Complete Registration!