another high performance PHP framework – Yii

他有作 performance compare – 據說是最快的 PHP framework

看他的 features 寫的 , 一些 “先進” 的 framework 的功能他都具備

  • DAO , active record
  • Web 2.0 widget , 這個酷
  • Theming , layered caching scheme 這個 ci 沒有
  • 2A , authentication and authorization , role-based 這個拿來作後台管理功能應該很方便

不過 那條紅色的線 可以不用看 , 看藍色那條是比 codeigniter 快 1/3 , 有空要來玩一下

http://www.yiiframework.com/performance

image

簡單方便的 RSS 工具程式 Feedcreator

http://feedcreator.org/

include("include/feedcreator.class.php");

$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = "PHP news";
$rss->description = "daily news from the PHP scripting world";
$rss->link = "http://www.dailyphp.net/news";
$rss->syndicationURL = "http://www.dailyphp.net/".$PHP_SELF;

$image = new FeedImage();
$image->title = "dailyphp.net logo";
$image->url = "http://www.dailyphp.net/images/logo.gif";
$image->link = "http://www.dailyphp.net";
$image->description = "Feed provided by dailyphp.net. Click to visit.";
$rss->image = $image;

// get your news items from somewhere, e.g. your database:
mysql_select_db($dbHost, $dbUser, $dbPass);
$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC");
while ($data = mysql_fetch_object($res)) {
    $item = new FeedItem();
    $item->title = $data->title;
    $item->link = $data->url;
    $item->description = $data->short;
    $item->date = $data->newsdate;
    $item->source = "http://www.dailyphp.net";
    $item->author = "John Doe";
    
    $rss->addItem($item);
}

$rss->saveFeed("RSS1.0", "news/feed.xml");

田裡控窯

2009.0103 天氣晴 , 可以說天空一片雲也沒有

田裡的稻早已收割 , 在田裡的只剩下稻梗 , 還有一群麻雀

今天多了一群人搭了兩座土窯 , 就是挖田裡的泥土搭起來的 , 把土窯燒紅了

再把包好的地瓜 , 雞肉 , 玉米等都丟進去 , 就等著開窯來吃囉

當然要先運動一下 , 在田裡打個棒球吧

食物在土堆裡悶了1個半小時 , 肚子也餓了 , 接下來不用說了 , 這些食物一被挖出來

瞬間就被搶光了

很多人也許不知道 什麼是 控窯吧, 看照片的 step by step 吧 …

P026

P060

P054

P047 P050

P039 P024

P064 P077

Sample code , 用 getopt 取得 command line 的參數

5c30343361478502ed9711dd38115baf

#include "stdlib.h"
#include "stdio.h"
#include "getopt.h"
#include "string.h"

void print_help(int exval);
char program[100] = "sample";

int main(int argc, char *argv[]) {
  int opt;
  strcpy(program,argv[0]);
  if (argc == 1) print_help(1);
  while((opt = getopt(argc, argv, "hVvf:o:")) != -1) {
    switch(opt) {
      case 'h':
        print_help(0);
        break;
      case 'V':
        printf("%s", program);
        exit(0);
        break;
      case 'v':
        printf("%s: Verbose option is set '%c'\n", program, optopt);
        break;
      case 'f':
        printf("%s: Filename %s\n", program, optarg);
        break;
      case 'o':
        printf("Output: %s\n", optarg);
        break;
      case ':':
        fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", program, optopt);
        print_help(1);
        break;
      case '?':
        fprintf(stderr, "%s: Error - No such option: '%c'\n\n", program, optopt);
        print_help(1);
    }
  }
  
  for(; optind < argc; optind++) printf("argument: %s\n", argv[optind]);
  return 0;
}

// -----
void print_help(int exval) {
  printf("Usage: %s [-h] [-V] [-f FILE] [-o FILE]\n\n", program);
  printf(" -h print this help and exit\n");
  printf(" -V print version and exit\n\n");
  printf(" -v set verbose flag\n");
  printf(" -f FILE set intput file\n");
  printf(" -o FILE set output file\n\n");
  exit(exval);
}