이렇게 if문 한번에 쓰는것이 속도에 영향이 있을까요? 정보
이렇게 if문 한번에 쓰는것이 속도에 영향이 있을까요?본문
아래와 같이..if문을 하나하나 쓰다보니 코드가 지져분해서..
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
if($Site_URL=="/member.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/member.php");
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
if($Site_URL=="/learning.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/learning.php");
.
.
.
--------------------------------------------------------------------------------------------
<?
if($Site_URL=="/index.php"||$Site_URL=="/bbs/bbs/register.php"||$Site_URL=="/interich.php"||$Site_URL=="/paytest.php"||
$Site_URL=="/card/redirpath.php"||$Site_URL=="/pay2.php"||$Site_URL=="/bbs/bbs/register_form.php"||$Site_URL=="/bbs/bbs/register_result.php"||
$Site_URL=="/bbs/bbs/member_confirm.php"||$Site_URL=="/pay.php"||$Site_URL=="/bbs/bbs/search.php"||$Site_URL=="/bbs/bbs/login.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/main3.php");
}
if($bo_table =="board5_1"||$bo_table =="board5_2"||$bo_table =="board5_3"||$bo_table =="board5_4"||$bo_table =="board5_5"||
$bo_table =="board5_6"||$bo_table =="board5_7"||$bo_table =="board5_8"||$bo_table =="board5_9"||$bo_table =="board5_10"){ //공지사항
include_once("$g4[path]/menu/notice.php");
}
if($bo_table =="board6_1"||$bo_table =="board6_2"||$bo_table =="board6_3"||$bo_table =="board6_4"||$bo_table =="board6_5"
||$bo_table =="board6_6"||$bo_table =="board6_7"||$bo_table =="board6_8"||$bo_table =="board6_9"||$bo_table =="board6_10"){ //처음오신분
include_once("$g4[path]/menu/information.php");
}
if($bo_table =="board1_1"||$bo_table =="board1_2"||$bo_table =="board1_3"||$bo_table =="board1_4"||$bo_table =="board1_5"
||$bo_table =="board1_6"||$bo_table =="board1_7"||$bo_table =="board1_8"||$bo_table =="board1_9"||$bo_table =="board1_10"
||$bo_table =="board1_11"||$bo_table =="board1_12"||$bo_table =="board1_13"||$bo_table =="board1_14"||$bo_table =="board1_15"
||$bo_table =="board1_16"||$bo_table =="board1_17"||$bo_table =="board1_18"||$bo_table =="board1_19"){ //투잡학습하기
include_once("$g4[path]/menu/learning2.php");
}
if($bo_table =="board_7_1"||$bo_table =="board_7_2"||$bo_table =="board_7_3"||$bo_table =="board_7_4"||$bo_table =="board_7_5"
||$bo_table =="board_7_6"||$bo_table =="board_7_7"||$bo_table =="board_7_8"||$bo_table =="board_7_9"||$bo_table =="board_7_10"){ //커뮤니티
include_once("$g4[path]/menu/community.php");
}
if($bo_table =="board3_1"||$bo_table =="board3_2"||$bo_table =="board3_3"||$bo_table =="board3_4"||$bo_table =="board3_5"
||$bo_table =="board3_6"||$bo_table =="board3_7"||$bo_table =="board3_8"||$bo_table =="board3_9"||$bo_table =="board3_10"){ //쉬어가기
include_once("$g4[path]/menu/fun.php");
}
if($bo_table =="board4_1"||$bo_table =="board4_2"||$bo_table =="board4_3"||$bo_table =="board4_4"||$bo_table =="board4_5"
||$bo_table =="board4_6"||$bo_table =="board4_7"||$bo_table =="board4_8"||$bo_table =="board4_9"||$bo_table =="board4_10"){ //고객센터
include_once("$g4[path]/menu/help.php");
}
?>
이렇게 if문을 한방에 썼습니다..
근데..다소 사이트 속도가 느려지는 듯한 느낌을 받는데..
이렇게 if문 한번에 쓰는것이 속도에 영향이 있을까요?
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
if($Site_URL=="/member.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/member.php");
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
if($Site_URL=="/learning.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/learning.php");
.
.
.
--------------------------------------------------------------------------------------------
<?
if($Site_URL=="/index.php"||$Site_URL=="/bbs/bbs/register.php"||$Site_URL=="/interich.php"||$Site_URL=="/paytest.php"||
$Site_URL=="/card/redirpath.php"||$Site_URL=="/pay2.php"||$Site_URL=="/bbs/bbs/register_form.php"||$Site_URL=="/bbs/bbs/register_result.php"||
$Site_URL=="/bbs/bbs/member_confirm.php"||$Site_URL=="/pay.php"||$Site_URL=="/bbs/bbs/search.php"||$Site_URL=="/bbs/bbs/login.php"){ //이용안내 페이지일 때 실행
include_once("$g4[path]/menu/main3.php");
}
if($bo_table =="board5_1"||$bo_table =="board5_2"||$bo_table =="board5_3"||$bo_table =="board5_4"||$bo_table =="board5_5"||
$bo_table =="board5_6"||$bo_table =="board5_7"||$bo_table =="board5_8"||$bo_table =="board5_9"||$bo_table =="board5_10"){ //공지사항
include_once("$g4[path]/menu/notice.php");
}
if($bo_table =="board6_1"||$bo_table =="board6_2"||$bo_table =="board6_3"||$bo_table =="board6_4"||$bo_table =="board6_5"
||$bo_table =="board6_6"||$bo_table =="board6_7"||$bo_table =="board6_8"||$bo_table =="board6_9"||$bo_table =="board6_10"){ //처음오신분
include_once("$g4[path]/menu/information.php");
}
if($bo_table =="board1_1"||$bo_table =="board1_2"||$bo_table =="board1_3"||$bo_table =="board1_4"||$bo_table =="board1_5"
||$bo_table =="board1_6"||$bo_table =="board1_7"||$bo_table =="board1_8"||$bo_table =="board1_9"||$bo_table =="board1_10"
||$bo_table =="board1_11"||$bo_table =="board1_12"||$bo_table =="board1_13"||$bo_table =="board1_14"||$bo_table =="board1_15"
||$bo_table =="board1_16"||$bo_table =="board1_17"||$bo_table =="board1_18"||$bo_table =="board1_19"){ //투잡학습하기
include_once("$g4[path]/menu/learning2.php");
}
if($bo_table =="board_7_1"||$bo_table =="board_7_2"||$bo_table =="board_7_3"||$bo_table =="board_7_4"||$bo_table =="board_7_5"
||$bo_table =="board_7_6"||$bo_table =="board_7_7"||$bo_table =="board_7_8"||$bo_table =="board_7_9"||$bo_table =="board_7_10"){ //커뮤니티
include_once("$g4[path]/menu/community.php");
}
if($bo_table =="board3_1"||$bo_table =="board3_2"||$bo_table =="board3_3"||$bo_table =="board3_4"||$bo_table =="board3_5"
||$bo_table =="board3_6"||$bo_table =="board3_7"||$bo_table =="board3_8"||$bo_table =="board3_9"||$bo_table =="board3_10"){ //쉬어가기
include_once("$g4[path]/menu/fun.php");
}
if($bo_table =="board4_1"||$bo_table =="board4_2"||$bo_table =="board4_3"||$bo_table =="board4_4"||$bo_table =="board4_5"
||$bo_table =="board4_6"||$bo_table =="board4_7"||$bo_table =="board4_8"||$bo_table =="board4_9"||$bo_table =="board4_10"){ //고객센터
include_once("$g4[path]/menu/help.php");
}
?>
이렇게 if문을 한방에 썼습니다..
근데..다소 사이트 속도가 느려지는 듯한 느낌을 받는데..
이렇게 if문 한번에 쓰는것이 속도에 영향이 있을까요?
댓글 전체
연산속도를 높이고 가독성을 위해서라도 다소 정리할 필요가 있겠네요...
만약 저라면 그룹을 만들고 같은 종류의 게시판을 묶습니다.
(예 : board1_1~~~board1_10 의 그룹아이디는 board1)
$array['a'] = array('a.php', 'b.php', 'c.php');
$array['b'] = array('d.php', 'e.php', 'f.php');
...
if($board['gr_id'] == 'board_1') include_once("$g4[path]/menu/aaa.php");
...
else if(in_array($Site_URL, $array['a']) == true) include_once("$g4[path]/menu/xxx.php");
else if(in_array($Site_URL, $array['b']) == true) include_once("$g4[path]/menu/yyy.php");
...
else include_once("$g4[path]/menu/zzz.php");
만약 저라면 그룹을 만들고 같은 종류의 게시판을 묶습니다.
(예 : board1_1~~~board1_10 의 그룹아이디는 board1)
$array['a'] = array('a.php', 'b.php', 'c.php');
$array['b'] = array('d.php', 'e.php', 'f.php');
...
if($board['gr_id'] == 'board_1') include_once("$g4[path]/menu/aaa.php");
...
else if(in_array($Site_URL, $array['a']) == true) include_once("$g4[path]/menu/xxx.php");
else if(in_array($Site_URL, $array['b']) == true) include_once("$g4[path]/menu/yyy.php");
...
else include_once("$g4[path]/menu/zzz.php");
이렇게 수정해 보았습니다..^^
<?
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
$aBoTable = array('/index.php' , '/pay.php','/bbs/bbs/register.php','/interich.php','/paytest.php','/card/redirpath.php','/pay2.php
','/bbs/bbs/register_form.php','/bbs/bbs/register_result.php','/bbs/bbs/member_confirm.php','/bbs/bbs/search.php','/bbs/bbs/login.php') ;
$bBoTable = array('/fun.php' , '/url/saju.php','/url/saju1.php','/url/saju2.php') ;
if( in_array( $Site_URL , $aBoTable ) ) { include_once("$g4[path]/menu/main3.php"); }
if( in_array( $Site_URL , $bBoTable ) ) { include_once("$g4[path]/menu/fun.php"); }
if($Site_URL=="/member.php"){include_once("$g4[path]/menu/member.php"); }
if($Site_URL=="/learning.php"){include_once("$g4[path]/menu/learning.php"); }
if($Site_URL=="/help.php"){ include_once("$g4[path]/menu/help.php"); }
if($Site_URL=="/information.php"){include_once("$g4[path]/menu/information.php"); }
if($Site_URL=="/notice.php"){ include_once("$g4[path]/menu/notice.php"); }
if($Site_URL=="/commuinty.php"){include_once("$g4[path]/menu/community.php"); }
if($board['gr_id'] == 'board_1'){ include_once("$g4[path]/menu/learning2.php"); } //투잡학습하기
if($board['gr_id'] == 'board_3'){ include_once("$g4[path]/menu/fun.php"); }//쉬어가기
if($board['gr_id'] == 'board_4'){ include_once("$g4[path]/menu/help.php"); } //고객센터
if($board['gr_id'] == 'board_5'){ include_once("$g4[path]/menu/notice.php"); } //공지사항
if($board['gr_id'] == 'board_6'){ include_once("$g4[path]/menu/information.php"); } //처음오신분
if($board['gr_id'] == 'board_7'){ include_once("$g4[path]/menu/community.php"); } //커뮤니티
?>
<?
$Site_URL = $PHP_SELF; //현재 페이지 이름을 담는다
$aBoTable = array('/index.php' , '/pay.php','/bbs/bbs/register.php','/interich.php','/paytest.php','/card/redirpath.php','/pay2.php
','/bbs/bbs/register_form.php','/bbs/bbs/register_result.php','/bbs/bbs/member_confirm.php','/bbs/bbs/search.php','/bbs/bbs/login.php') ;
$bBoTable = array('/fun.php' , '/url/saju.php','/url/saju1.php','/url/saju2.php') ;
if( in_array( $Site_URL , $aBoTable ) ) { include_once("$g4[path]/menu/main3.php"); }
if( in_array( $Site_URL , $bBoTable ) ) { include_once("$g4[path]/menu/fun.php"); }
if($Site_URL=="/member.php"){include_once("$g4[path]/menu/member.php"); }
if($Site_URL=="/learning.php"){include_once("$g4[path]/menu/learning.php"); }
if($Site_URL=="/help.php"){ include_once("$g4[path]/menu/help.php"); }
if($Site_URL=="/information.php"){include_once("$g4[path]/menu/information.php"); }
if($Site_URL=="/notice.php"){ include_once("$g4[path]/menu/notice.php"); }
if($Site_URL=="/commuinty.php"){include_once("$g4[path]/menu/community.php"); }
if($board['gr_id'] == 'board_1'){ include_once("$g4[path]/menu/learning2.php"); } //투잡학습하기
if($board['gr_id'] == 'board_3'){ include_once("$g4[path]/menu/fun.php"); }//쉬어가기
if($board['gr_id'] == 'board_4'){ include_once("$g4[path]/menu/help.php"); } //고객센터
if($board['gr_id'] == 'board_5'){ include_once("$g4[path]/menu/notice.php"); } //공지사항
if($board['gr_id'] == 'board_6'){ include_once("$g4[path]/menu/information.php"); } //처음오신분
if($board['gr_id'] == 'board_7'){ include_once("$g4[path]/menu/community.php"); } //커뮤니티
?>
굳이 저렇게 해야될 이유가 있나요? ^^;; 결국 불러오는 파일들도 독립된 파일일 텐데요.