-
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/64
Originally posted by JoisFe March 4, 2023
71. 하나의 파일을 여러 곳에서 사용하기 require
require
- include와 같이 다른 페이지를 불러오는 방법으로 require 존재
require 사용 방법
reauire "파일 경로와 파일명;"

- a.php
<?php
echo "hi";
?>
- b.php
<?php
require "./a.php";
?>
- b.php를 실행시켜보면

- include와 require은 같은 기능을 가짐
- 완전히 같다면 2개로 있을 필요가 없음 즉 차이가 있음
include vs require
include
- 불러오는 파일의 경로나 파일명에 문제가 있더라도 오류를 발생시키지 않음
require
- 불러오는 파일의 경로나 파일명에 문제가 있으면 오류를 발생시킴

<?php
require "./nonFile.php";
echo "페이지에 오류 생김";
?>
