Blog บทความ ความรู้ ประสบการณ์ หรือแปล เกี่ยวกับ PHP และเทคโนโลยีที่เกี่ยวข้อง นอกจากนี้ยังมี php forum ถาม-ตอบ ทุกคำถาม จะมีคำตอบ ... ที่นี่ - Blog and forum from the PHP zealots and PHP user groups in Thailand
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • warning: Parameter 1 to theme_field() expected to be a reference, value given in /var/www/phpzealots.com/drupal-5.15/includes/theme.inc on line 171.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.
  • : Function ereg() is deprecated in /var/www/phpzealots.com/drupal-5.15/includes/file.inc on line 649.

ไม่ต้องการ render Layout และ/หรือ View ใน Zend Framework หรือ ZF

ในบางครั้งเราอาจไม่ต้องการ render view และ/หรือ layout เช่นกรณีเราทำ Ajax Controller ก็ไม่อยากจะแสดง layout รวม อยากแสดงแค่ json หรือ xml เราก็เซตได้ครับ ดังนี้ครับ
      $this->_helper->layout->disableLayout();
      $this->_helper->viewRenderer->setNoRender(TRUE);
โดยแป่ะไว้ที่ action เกี่ยวข้อง หรือ ไว้ใน init() ของ controller ที่เกี่ยวข้องก้ได้ แล้วแต่สะดวกครับ

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 ปนนี่ ... ดูยาก และแก้ยากชะมัด) เชื่อมั้ย ว่ายังมีคนเขียนปนอย่างนี้อยู่ :)

ลบข้อมูลจาก Spammers!

หลังจากไม่ได้ดูแล phpzealots มานานแสนนาน ก็กลายเป็นแหล่งเสื่อมโทรมจากพี่ๆ spammers วันนี้เลยจะมาลบข้อมูลขยะเหล่านั้นซะหน่อย

ในเบื้องต้นผมใช้ script นี้ครับในการ clear แต่ก็ยังลบไม่หมดหรอก คงต้อง manual อีกซักหน่อย เพราะว่าเยอะเหลือเกิน
<?php
  // ตารางที่มี field: uid
  $tables = array(
    'd_accesslog', 'd_authmap', 'd_blogapi_files', 'd_comments',
    'd_history', 'd_node', 'd_node_revisions', 'd_poll_votes',
    'd_profile_values', 'd_sessions', 'd_userpoints',
    'd_userpoints_txn', 'd_users', 'd_users_roles',
    'd_users_signature', 'd_user_postcounts', 'd_user_titles_posts',
    'd_watchdog',
  );
 
  mysql_connect('localhost', 'xxx', 'xxx') or die(mysql_error());
  mysql_select_db('xxx');
 
  $uids = array();
  for ($uid = 5000; $uid <= 10000; $uid++) {
    $uids[] = $uid;
  }
  foreach ($tables as $tab) {
    $delCmd = 'DELETE FROM ' . $tab . ' WHERE uid IN (' . implode(',', $uids) . ') ';
    @mysql_query($delCmd);
    echo $delCmd . ' done' . "\n";
  }
  mysql_close();
?>

FCKeditor Current Release 2.6.4.1

WYSIWYG เจ้านึงที่ดังเหมือนกัน ... ไม่ได้ดูนาน (เพราะไม่ได้ใช้เลย) ตอนนี้เวอร์ชั่น ปาเข้าไป 2.6.4.1 แล้ว

 

PHP 5.3.0 Released!

วันนี้ (2009-06-30) ทีมพัฒนา PHP ภูมิใจนำเสนอ PHP 5.3.0 release ล่าสุดและเป็น major change ของซีรี่ส์ 5.X ด้วย ในเวอร์ชั่นใหม่นี้มี features ใหม่ๆ และ bug fix เพียบ

ฟีเจอร์หลักๆ ใน PHP 5.3.0 ประกอบด้วย:

YUI 3.0.0 beta 1

รายละเอียด ... อืิม  มันเขียนยาก น่ะ

เ้ข้าไปดูจาก เว็บเลยแล้วกันคับ

เวอร์ชัน releases
http://yuiblog.com/blog/2009/06/24/yui3b1/

ตัวอย่างนะ
http://developer.yahoo.com/yui/3/examples/

 

วีดีโอ คร่า่วๆ

 

PHP 5.2.10 Released

The PHP development team would like to announce the immediate availability of PHP 5.2.10. This release focuses on improving the stability of
the PHP 5.2.x branch with over 100 bug fixes, one of which is security related. All users of PHP are encouraged to upgrade to this release.

Security Enhancements and Fixes in PHP 5.2.10:

       Fixed bug #48378 (exif_read_data() segfaults on certain corrupted .jpeg files).

Key enhancements in PHP 5.2.10 include:

       Added "ignore_errors" option to http fopen wrapper.
       Fixed memory corruptions while reading properties of zip files.
       Fixed memory leak in ob_get_clean/ob_get_flush.
       Fixed segfault on invalid session.save_path.
       Fixed leaks in imap when a mail_criteria is used.
       Changed default value of array_unique()'s optional sorting type parameter back to SORT_STRING to fix backwards compatibility breakage introduced in PHP 5.2.9.
       Fixed bug #47940 (memory leaks in imap_body).
       Fixed bug #47903 ("@" operator does not work with string offsets).
       Fixed bug #47644 (Valid integers are truncated with json_decode()).
       Fixed bug #47564 (unpacking unsigned long 32bit big endian returns wrong result).
       Fixed bug #47365 (ip2long() may allow some invalid values on certain 64bit systems).
       Over 100 bug fixes.
 

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();

JSON หรือ XML ดี ???

JSON และ XML เราควรจะใช้ในสถานการณ์อย่างไรดี ??

ขอความรู้ และความเห็นหน่อยครับ :D

YUI 2.7.0 Released

สำหรับ เวอร์ชันใหม่ 2.7.0 นี้ มีคอมโำำพเนนต์ใหม่ ด้วยคือ

StyleSheet Utility

คุณสมบัติเด่นๆ ก็เป็นลักษณะการทำ dynamic css เราสามารถปรับ หรือเปลี่ยนรูปแบบของ element ต่างๆ ได้ทันที ( create and modify CSS stylesheets on the fly. ) โดยไม่ต้อง รีโหลดหน้่านั้น ขึ้นมาใหม่

นอกนั้น ก็ มีการปรับปรุงและเพิ่มเติมอื่นๆ เช่น

- 3 คอมโพเนนต์ที่ปรับจาก เวอร์ชัน เบต้า ได้แก่

 

- รองรับการใช้งานกับ IE8

- ฟิกบัก มากกว่า 180 จุด

นอกจากจากนี้ ยังมีการ อับเดท แล้วก็ เพิ่้มเติมตัวอย่างเป็น กว่า 300 ตัวอย่างอย่างการใช้งาน

 สำหรับ ข้อมูลเพิ่มเติม อื่นๆ นอกจาก หาได้ที่

Tags



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