2013年2月27日 星期三

【php】__autoload、spl_autoload_register

今天看 yii framework 看到有趣的功能

__autoload、spl_autoload_register()
會自動找class
如:
aa_class.php
class aa {
 function doPrint() {
  echo 'hello world';
 }
}

index.php
function __autoload( $class ) {
 $file = $class . '_class.php'; 
 if ( is_file($file) ) { 
  require_once($file); 
 }
}

$obj = new aa();
$obj->doPrint();

function loadprint( $class ) {
 $file = $class . '.class.php'; 
 if (is_file($file)) { 
  require_once($file); 
 }
}
spl_autoload_register( 'loadprint' );

$obj = new aa();
$obj->doPrint();

都會印出 hello world 就不用一直include

2013年2月20日 星期三

【jquery ui】sort 存儲存值及限制個數

$( "ul.droptrue" ).sortable({
 connectWith: "ul"
});

$( "ul.dropfalse" ).sortable({
 connectWith: "ul",
 update: function( event, ui ) {
  var result = $(this).sortable('toArray');
  alert(result);
  if (result.length > 2){
   alert('最多只能放2個');
   $( ".droptrue" ).sortable( "cancel" );
  }
 }
});

2013年2月19日 星期二

【php】private、protected、public、published


private
  放的是類別欄位、內容演算、處理,或屬性存取方法.
protected
除了後代可存取,其它的都不可存取.
放的是讓後代可操作的欄位,處理方法,或預留一些給後代公開的方法.
public
完全公開.
published
公開並且擁有RTTI資訊.放的是屬性及事件

2013年2月4日 星期一

【vm】VM9 裝mac os

1.先要有dmg檔在轉成ISO檔
  下載下來的dmg檔要用7-zip開啟裡面才有真正的dmg抓出來後
  用dmg2img轉成iso






















2.vm要安裝支援補丁unlock-all-v110裝好後就能選到mac os
  再參考http://www.33lc.com/article/4344.html就成功了