๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Lect & Tip/PHP & WordPress

asp, html, jsp, php include(์ธํด๋ฃจ๋“œ) ํ•˜๋Š” ๋ฐฉ๋ฒ•.

by ๋‚ฏ์„ ๊ณต๊ฐ„2019 2018. 12. 11.

๋ชฉ์ฐจ

    HTML,JSP,PHP,ASP include(์ธํด๋ฃจ๋“œ) ํ•˜๋Š” ๋ฐฉ๋ฒ•.

    ๊ฐ ์–ธ์–ด์—์„œ ์ธํด๋ฃจ๋“œ(include)๋ฌธ์€ ๋ฐ˜๋ณต์ ์œผ๋กœ ์‚ฝ์ž…๋˜๊ฑฐ๋‚˜, ์žฌ์‚ฌ์šฉ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

    ์›น์‚ฌ์ดํŠธ๋‚˜ ์–ดํ”Œ์„ ๊ฐœ๋ฐœํ•˜๋Š” ๊ฐœ๋ฐœ์ž๋“ค์ด ํ”„๋กœ๊ทธ๋žจ์„ ์งค ๋•Œ ์ด์™ธ์—๋„ ์›นํผ๋ธ”๋ฆฌ์…”๋“ค๋„ ์ธํด๋Ÿฌ๋“œ๋ฅผ ์ž์ฃผ ํ™œ์šฉํ•œ๋‹ค.

    ์›นํผ๋ธ”๋ฆฌ์…”๋“ค์ด include ํ•จ์ˆ˜๋ฅผ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š” ํ—ค๋”(Header), ํ‘ธํ„ฐ(Footer)์™€ ๋„ค๋น„๊ฒŒ์ด์…˜ ๋“ฑ์˜ ์‚ฌ์ดํŠธ ์ „๋ฐ˜์— ๊ฑธ์ณ์„œ ๊ณตํ†ต ์˜์—ญ๊ณผ ๊ฐ™์ด ๋ฐ˜๋ณต๋˜๋Š” ์˜์—ญ์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ์“ด๋‹ค.

    ์ด๋ ‡๊ฒŒ ์ธํด๋ฃจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด, ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ ์ค‘ ๊ณตํ†ต์˜์—ญ์˜ ์ˆ˜์ •๊ณผ ๊ด€๋ฆฌ๊ฐ€ ์šฉ์ด ํ•˜๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค.

    ํ•˜์ง€๋งŒ, ์ œ๋ชฉ์— HTML ์ธํด๋ฃจ๋“œ ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ผ์ง€๋งŒ HTML์€ include๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

    ๋”ฐ๋ผ์„œ ์›น์„œ๋ฒ„ ํ™˜๊ฒฝ์ด ๊ตฌ์ถ•๋˜์ง€ ์•Š๊ณ  ๋‹จ์ˆœํžˆ html๋งŒ ์ฝ”๋”ฉํ•˜๋Š” ์ž‘์—…๋ฐฉ์‹์—์„œ๋Š” ์“ธ ์ˆ˜ ์—†๋‹ค.

    PHP include

    <? include("../์ƒ๋Œ€๊ฒฝ๋กœ/file/file.php");?>

    <? include("/์ ˆ๋Œ€๊ฒฝ๋กœ/file/file.php");?>

    ๋˜๋Š”

    <?php include("../์ƒ๋Œ€๊ฒฝ๋กœ/file.php");?>

    <?php include("/์ ˆ๋Œ€๊ฒฝ๋กœ/file/file.php");?>

    ASP include

    <!-- #include file="../์ƒ๋Œ€๊ฒฝ๋กœ/file๋ช….asp"-->  '๋‹ค๋ฅธ ํƒœ๊ทธ์˜ ๋‚ด์šฉ์ด ์ œ๋Œ€๋กœ ๋ณด์ธ๋‹ค.

    <!-- #include virtual="/์ ˆ๋Œ€๊ฒฝ๋กœ/file๋ช….asp"-->  ' ์ง€์ •๋œ ๊ฒฝ๋กœ/file์™ธ์˜ ๋‹ค๋ฅธ ํƒœ๊ทธ์˜ ๋‚ด์šฉ์€ ์ œ๋Œ€๋กœ ๋ณด์ด์ง€ ์•Š๋Š”๋‹ค.

    JSP include

    <%@ include file="../์ƒ๋Œ€๊ฒฝ๋กœ/file.jsp" %

    ๋˜๋Š” 

    <%@ include file="/์ ˆ๋Œ€๊ฒฝ๋กœ/file.jsp" %>

    ๋˜๋Š” 

    <jsp:include page="../์ƒ๋Œ€or์ ˆ๋Œ€๊ฒฝ๋กœ/file.jsp" flush="true" />

    ์˜ค๋Š˜์˜ ์งค๋ฐฉ์€~ ์ฒญ์ˆœํ•œ ๋ฐ€๋ฆฌํ„ฐ๋ฆฌ ๋ฃฉ ๋ฏธ๋‹ˆ์Šค์ปคํŠธ์˜ ์ญ‰ ๋ป—์€ ๊ฐ์„ ๋ฏธ~^^;

    ๊ฒ€์Šค๋…€ ๋ฏธ๋‹ˆ์Šค์ปคํŠธ ๊ฐ์„ ๋ฏธ ๋ชธ๋งค
    ์งค๋ฐฉ : ๊ฒ€์Šค๋…€ ๋ฏธ๋‹ˆ์Šค์ปคํŠธ ๊ฐ์„ ๋ฏธ ๋ชธ๋งค

    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€