PHP Functions ที่ควรรู้และมีประโยชน์อย่างมาก

PHP Functions ที่ควรรู้และมีประโยชน์อย่างมาก

1. การส่งและรับค่า Arguments ของฟังก์ชันได้ไม่จำกัด โดยไม่จำเป็นต้องกำหนด Arguments ตอนประกาศฟังก์ชัน function foo() { // returns an array of all passed arguments $args = func_get_args(); foreach ($args as $k => $v) { echo “arg”.($k+1).”: $v\n”; } } foo(); /* prints nothing */ foo(‘hello’, ‘world’); … Continue reading

การตรวจสอบ Browser ว่าอยู่บน Mobile Platform ใด ด้วย JavaScript

การตรวจสอบ Browser ว่าอยู่บน Mobile Platform ใด ด้วย JavaScript

var ua = navigator.userAgent.toLowerCase(); var ua_checker = { android: ua.match(/android/), iphone: ua.match(/(iphone|ipod|ipad)/), blackberry: ua.match(/blackberry/) }; if (ua_checker.android) { // up to you } else if (ua_checker.iphone) { // up to you } else if (ua_checker.blackberry) { // up to you … Continue reading

การตรวจสอบ Browser ว่าอยู่บน Mobile Platform ใด ด้วย PHP

การตรวจสอบ Browser ว่าอยู่บน Mobile Platform ใด ด้วย PHP

$ua = strtolower($_SERVER['HTTP_USER_AGENT']); $ua_checker = array( ‘android’=>preg_match(‘/android/’, $ua), ‘iphone’=>preg_match(‘/iphone|ipod|ipad/’, $ua), ‘blackberry’=>preg_match(‘/blackberry/’, $ua) ) if ($ua_checker['android']) { // up to you } else if ($ua_checker['iphone']) { // up to you } else if ($ua_checker['blackberry']) { // up to you }