• warning: Invalid argument supplied for foreach() in /var/www/phpzealots.com/drupal-5.15/sites/all/modules/cck/fieldgroup.module on line 394.
  • warning: Invalid argument supplied for foreach() in /var/www/phpzealots.com/drupal-5.15/sites/all/modules/cck/fieldgroup.module on line 394.
  • warning: Invalid argument supplied for foreach() in /var/www/phpzealots.com/drupal-5.15/sites/all/modules/cck/fieldgroup.module on line 394.
  • warning: Invalid argument supplied for foreach() in /var/www/phpzealots.com/drupal-5.15/sites/all/modules/cck/fieldgroup.module on line 394.
  • warning: Invalid argument supplied for foreach() in /var/www/phpzealots.com/drupal-5.15/sites/all/modules/cck/fieldgroup.module on line 394.

PHP Basics

Coding Standard

 ว่างๆ หรือวันไหนอากาศดีๆ ลองปรับตัวเอง ใส่ใจในการเขียน code มากขึ้นซักเล็กน้อย โดยยึดตามอันนี้ก็ได้ครับ

http://framework.zend.com/manual/en/coding-standard.coding-style.html

code เราจะได้สวยๆ และเวลาคนอื่นมาไล่ จะได้ไม่บ่นมาก :D นอกจากโปรแกรมจะมั่วแล้ว ก็อย่าให้ code มันมั่วมากนักเลย หุหุ

แล้วก็พยายามเลี่ยงเขียน html ปนเข้าไปใน php script (html ปนน้ะครับ ไม่ใช่ php embed ใน html อย่างหลังนี่เป็นเรื่องธรรมดา เวลาที่เราเขียนแบบ MVC แต่แบบ html ปนนี่ ... ดูยาก และแก้ยากชะมัด) เชื่อมั้ย ว่ายังมีคนเขียนปนอย่างนี้อยู่ :)

n/a

n/a

n/a

n/a

n/a

Convert Exif 'GPSLatitude' และ 'GPSLongitude' เป็น lat, lng เพื่อ นำไปปักหมุดใน Google Maps

 

    $rawExif = exif_read_data($imgName);
    if( isset($rawExif['GPSLatitude']) )
    {
      eval('$degree = $rawExif["GPSLatitude"][0];');
      eval('$mins   = $rawExif["GPSLatitude"][1];');
      eval('$secs   = $rawExif["GPSLatitude"][2];');
      $lat = $degree + ( $mins / 60 ) + ( $secs / 3600 ); 
      if( $rawExif['GPSLatitudeRef'] == 'S' )
      {
        $lat = (-1) * $lat;
      }

      eval('$degree = $rawExif["GPSLongitude"][0];');
      eval('$mins   = $rawExif["GPSLongitude"][1];');
      eval('$secs   = $rawExif["GPSLongitude"][2];');
      $lng = $degree + ( $mins / 60 ) + ( $secs / 3600 ); 
      if( $rawExif['GPSLongitudeRef'] == 'W' )
      {
        $lng = (-1) * $lng;
      }
      
      echo "$lat, $lng";
    }

 

อ้างอิง: http://andrew.hedges.name/experiments/convert_lat_long/

Design Pattern :: Strategy Pattern

Strategy Pattern เป็น design pattern ที่เอาไว้ใช้ตอนที่เราต้องเลือกทำสิ่งหนึ่ง แต่วิธีการหลากหลายออกไป เช่น เราจะสร้างระบบแจ้งเตือน user ซึ่งสามารถเตือนได้ทั้งแบบ e-mail sms และ fax pattern นี้ต้องการ interface ตัวนึง เราให้ชื่อว่า notifier คลาสที่ implements ก็จะมี EmailNotifier, SMSNotifier และ FaxNotifier ซึ่งเป็นวิธีการแจ้งเตือน user นั่นเอง โค้ด

 <?php
 
class User {
    private $name;
    protected $notifier;
 
    public function __construct($name) {
        $this->name = $name;
    }
    public function setNotifier(INotifier $notifier) {
        $this->notifier = $notifier;
    }
    public function notify() {
        $this->notifier->notify();
    }
}
 
interface INotifier {
    public function notify();
}
 
class EmailNotifier implements INotifier {
    public function notify() {
        echo "Notify by Email";
    }
}
 
class SMSNotifier implements INotifier {
    public function notify() {
        echo "Notify by SMS";
    }
}
 
class FaxNotifier implements INotifier {
    public function notify() {
        echo "Notify by Fax";
    }
}
 
$john = new User('John');
$smith = new User('Smith');
$edward = new User('Edward');
 
$john->setNotifier(new EmailNotifier());
$smith->setNotifier(new SMSNotifier());
$edward->setNotifier(new FaxNotifier());
 
$john->notify();
$smith->notify();
$edward->notify();

สอบถามเรื่อง curl ครับ

คือ ผมลง Zen cart ที่เป็น cms นั้นพบว่า มันมีปัญหาเรื่อง curl จึงอยากทราบว่าควรทำอย่างไรครับ คือไม่มีความรุ้เรื่องนี้ช่วยแนะนำหน่อยครับ ทั้งวิธีติดตั้งและ วิธีใช ด้วยครับ ขอบคุณ

อยากได้ visual basic 6.0

ขอขอบคุณล่วงหน้าเลยนะคับ


©2007-2010 PHPZealots.com. All right reserved.
Syndicate content