'type'에 해당되는 글 2건
- 2009/07/07 PHP - Detects what compression file uses
- 2009/01/06 C# ?? 연산자(Operator)
유명한 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';
}
'Program > PHP' 카테고리의 다른 글
| PHP - Detects what compression file uses (0) | 2009/07/07 |
|---|---|
| PHP on IIS 7.0, 6.0, 5.1 with Fast CGI (0) | 2009/02/01 |
| PHP : natsort() Natural order sorting 로 숫자를 제대로 정렬 (0) | 2007/05/25 |
| PHP 성능 최적화를 위한 방향 (0) | 2007/05/22 |
이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^
'??' 연산자는 변수안의 값이 널이면 우측의 값을 널이 아니면 변수안의 값을 리턴하도록 하는 비교 연산자라 할 수 있다.
이는 .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";
'.NET > C#' 카테고리의 다른 글
| Use WebBrowser and shdocvw.dll for POST Data sending (0) | 2009/02/16 |
|---|---|
| C# - Excel Sheet to DataTable (2) | 2009/01/14 |
| C# ?? 연산자(Operator) (0) | 2009/01/06 |
| C# 웹페이지를 읽어 문자열로 반환하는 코드 (2) | 2008/06/18 |
| Reflection을 이용해 C# DLL 동적로드 (0) | 2008/06/10 |
| Mix08 ASP.NET MVC (0) | 2008/05/07 |
이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^

Prev




