지각생 연습장
[편집] 좋은 리소스
[편집] 프레임워크
[편집] PEAR
class mytable extends DB_DataObject {
var $_database_dsn = "mysql://username:password@localhost/database";
var $__table = "mytable";
function table() {
return array(
'id' => 1, //integer or number
'name' => 2, // string
}
}
function keys() {
return array('id');
}
}
$instance = new mytable;
$instance->get("id", 12);
echo $instance->somedata;
$instance->whereAdd("ID > 12");
$instance->whereAdd("ID < 14");
$instance->find();
while($instance->fetch()) {
echo $instance->somedata;
}
[편집] 정규표현식 모음
- 웹(ftp) 문서 패턴 : (http|ftp)://([0-9a-zA-Z./@~?&=_]+)
- 이메일 : ([_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*)@([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)
[편집] PHP5 컴파일 설치
[편집] 라이브러리 설치
- zlib - www.gzip.org/zlib, www.zlib.net. PHP의 zlib 확장 모듈이 제공하는 API를 통해 압축 파일을 읽고 쓸 수 있게 된다.
- iconv - 문자셋 변환 라이브러리
- libxml2 - XML문서 파싱 라이브러리, DOM, SAX, XSLT, SimpleXML 과 같은 확장 모듈의 기반
- libxslt - XML 문서를 다른 구조의 XML 또는 HTML 문서로 변환하는 기능 제공
- GD 설치
[편집] PHP5 컴파일
--with-apxs=/usr/local/www/bin/apxs
--with-zlib-dir=/usr/local
--with-iconv-dir=/usr/local
--with-libxml-dir=/usr/local
--with-xsl=/usr/local
--with-config-file-path=/usr/local/www/conf
--with-mod_charset
--enable-sigchild
[편집] PHP로 HTTP인증하기
[편집] 짤막 팁/소스
- 다른 페이지로 바로 이동 (인덱스 파일 등에서)
<? header("Location: 옮길위치"); ?>
- 제로보드 : 썸네일 이미지 표시하기 - 큰 이미지가 업로드되면, 자동으로 일정 폭 기준으로 크기를 변경한 썸네일을 생성하고, 표시한다. 썸네일은 업로드한 이미지를 최초로 열어볼 때 만들어진다.
<?php
list($image1_width, $image1_height) = getimagesize($data[file_name1]);
//$image1_width = imagesx($data[file_name1]);
if($image1_width && $image1_width > 580) $image1_width_new = 580;
else $image1_width_new = $image1_width;
//echo $data[file_name1]; echo $image1_width;
$image1_height_new = round($image1_height * 580 / $image1_width);
$thumb1 = thumb($id, $data[s_file_name1], 580, $image1_height_new); // x:y = newx: newy => newy = y*newx / x
$upload_image1 = str_replace("style=\"", "style=\"width: ${image1_width_new}px; ", $upload_image1);
$upload_image1 = preg_replace("/src=\S+ /", "src=$thumb1 ", $upload_image1);
if($data[file_name2]) {
list($image2_width, $image2_height) = getimagesize($data[file_name2]);
if($image2_width && $image2_width > 580) $image2_width_new = 580;
else $image2_width_new = $image2_width;
$image2_height_new = round($image2_height * 580 / $image2_width);
$thumb2 = thumb($id, $data[s_file_name2], 580, $image2_height_new);
$upload_image2 = str_replace("style=\"", "style=\"width: ${image2_width_new}px; ", $upload_image2);
$upload_image2 = preg_replace("/src=\S+ /", "src=$thumb2 ", $upload_image2);
}
?>
[편집] 전자상거래
[편집] 애플리케이션
[편집] 참고