Develop/PHP
PHP 모듈 표준 프로그래밍 가이드 +폴더 구성 + 코딩 스타일 가이드
다니엘SEO
2009. 8. 31. 06:02
★ 폴더 구성
bottom 디자인 하부 HTML 파일 모음
func 일반 함수 모음
images 전체 이미지
index
board
poll
login
shop
inc DB연결 or 상수 설정 파일
mysqls MySQL 함수 모음
pgm
board
qna Q&A게시판 메인 프로그램
news 공지사항 메인 프로그램
poll 온라인 폴
login 로그인
shop 쇼핑몰
scripts 자바스크립트
style CSS파일
top 디자인 상부 HTML모음
★ Q&A 게시판 파일 & 폴더
bottom
qna_bottom.php
func
qna_functions.php
images
index
board
poll
login
shop
inc
qna.inc.php
qna.txt.php
mysqls
qna_mysqls.php
pgm
board
qna
list.php
list_main.php
read.php
read_main.php
insert.php
insert_main.php
write.php
write_main.php
scripts
style
qna.css
top
qna_top.php
★ qna_bottom.php 파일에서 이미지 링크 다음과 같이 - htdocs 절대 경로 사용 !
<img src="/images/main/01.jpg">
★ read.php 파일에서
<?php
// 로그인 인증 절대 경로
include_once "$_SERVER[DOCUMENT_ROOT]/pgm/login/process_html.php";
include_once "$_SERVER[DOCUMENT_ROOT]/inc/qna.inc.php";
include_once "$_SERVER[DOCUMENT_ROOT]/inc/qna.txt.php";
include_once "$_SERVER[DOCUMENT_ROOT]/func/qna_functions.php";
include_once "$_SERVER[DOCUMENT_ROOT]/mysqls/qna_mysqls.php";
include_once "$_SERVER[DOCUMENT_ROOT]/top/qna_top.php";
// 같은 디렉토리에 있는 파일을 링크 할 경우를 제외하고 모두 절대 경로 사용 !
if(isset($board) and $board!='') {
$file = "read_main.php";
if(file_exists($file))
include_once($file);
}
include_once "$_SERVER[DOCUMENT_ROOT]/bottom/qna_bottom.php";
?>
★ include 문 사용하기
같은 디렉토리의 파일을 include 할 경우는 다음과 같이 한다.
include_once "aaa.php";
그러나 다른 디렉토리의 파일을 include 할 경우에는 반드시 다음과 같이 절대 경로를 쓴다.
include_once "$_SERVER[DOCUMENT_ROOT]/mysqls/aaa.php";
현재 디렉토리 아래 경우에도 마찬가지 이다. 되도록이면, 현재 디렉토리에 파일을 만들라 !
include_once "$_SERVER[DOCUMENT_ROOT]/mysqls/aaa.php"; 안에서 파일 include경우는 같은 디렉토리 일 경우는
include_once "bbb.php";로 가능하다.
HTML경로는 htdocs 절대 경로임 !
<img src="/images/">
[출처] PHP 모듈 표준 프로그래밍 가이드|작성자 정연아빠