-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Discussed in https://github.com/orgs/Programming-Language-Practice/discussions/61
Originally posted by JoisFe March 1, 2023
70. 하나의 파일을 여러 곳에서 사용하기 include
- 한 번 작성한 코드를 다른 곳에서도 사용해야하는 경우가 많음
- 만약 해당 코드를 계속 똑같이 작성한다면 효율이 좋지 않음
해결 방법 -> include 이용
include
include 사용 방법
include "파일 경로와 파일명";

- a.php
<?php
echo "hi";
?>

- 다른 파일에서 include 통한 결과를 확인해보면
- b.php
<?php
include "./a.php";
?>

- include 를 사용하니 a.php 파일을 잘 불러오는 것을 확인할 수 있다.