'type'에 해당되는 글 2건

  1. 2009/07/07 PHP - Detects what compression file uses
  2. 2009/01/06 C# ?? 연산자(Operator)
2009/07/07 00:35

PHP - Detects what compression file uses


유명한 MySQL 관리 툴이죠. phpMyAdmin 소스를 보던 중 좋은 내용을 발췌합니다.

libraries\import.lib.php 파일에 있던 내용이고요.

코드는 아래와 같습니다.



/**
 *  Detects what compression filse uses
 *
 *  @param  string filename to check
 *  @return string MIME type of compression, none for none
 *  @access public
 */
function PMA_detectCompression($filepath)
{
    $file = @fopen($filepath, 'rb');
    if (!$file) {
        return FALSE;
    }
    $test = fread($file, 4);
    $len = strlen($test);
    fclose($file);
    if ($len >= 2 && $test[0] == chr(31) && $test[1] == chr(139)) {
        return 'application/gzip';
    }
    if ($len >= 3 && substr($test, 0, 3) == 'BZh') {
        return 'application/bzip2';
    }
    if ($len >= 4 && $test == "PK\003\004") {
        return 'application/zip';
    }
    return 'none';
}

저작자 표시 비영리 변경 금지
크리에이티브 커먼즈 라이선스
Creative Commons License
올블로그추천버튼 블코추천버튼 블로그뉴스추천버튼 믹시추천버튼 한RSS추가버튼 구글리더기추천버튼


이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^


Trackback 0 Comment 0

Trackback : http://i-ruru.com/trackback/473 관련글 쓰기

2009/01/06 14:38

C# ?? 연산자(Operator)


'??' 연산자는 변수안의 값이 널이면 우측의 값을 널이 아니면 변수안의 값을 리턴하도록 하는 비교 연산자라 할 수 있다.

이는 .NET Framework 2.0 부터 있단 C# 2.0에 있던 내용인데
대부분의 사람들이 .NET Framework 3.0 이후 C# 3.0 이후의 내용으로 오해하는 경우가 많다.

VS 2005에서도 사용할 수 있는데... -_ -;

다들 착각하지 말고 2.0에서도 사용하시길~~

아래 내용은 참고 하는 소스를 해외 사이트에서 스크랩해온 내용..

참고하실 페이지의 주소는 다음과 같습니다.

PS. int? 와 같은 형식의 Nullable type도 .NET Framework 2.0에서 작동합니다. 아니라고 우기시는분들은 찾아보시길 -_ -;;

http://weblogs.asp.net/scottgu/archive/2007/09/20/the-new-c-null-coalescing-operator-and-using-it-with-linq.aspx
http://dotnettipoftheday.org/tips/double_question_mark_operator_cs.aspx
http://www.sturmnet.org/blog/archives/2005/06/15/doublequestionmark/
http://blog.devstone.com/Aaron/archive/2006/01/02/1404.aspx
http://mastersact.blogspot.com/2007/05/cs-operator.html




?? operator (C#)

The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. For example:

   

    int? x = null;

    ...

    // y = x, unless x is null, in which case y = -1.

    int y = x ?? -1;




The ?? operator also works with reference types:

  

  //message = param, unless param is null

    //in which case message = "No message"

    string message = param ?? "No message";


저작자 표시 비영리 변경 금지
크리에이티브 커먼즈 라이선스
Creative Commons License
올블로그추천버튼 블코추천버튼 블로그뉴스추천버튼 믹시추천버튼 한RSS추가버튼 구글리더기추천버튼


이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^


Trackback 0 Comment 0

Trackback : http://i-ruru.com/trackback/381 관련글 쓰기