다른 파일에서 불러올 때 사용한다.
one.php
<?php
function welcome(){
return 'hello!!';
}
echo welcome();
?>
two.php
<?php
// 파일이 없을 경우 include는 warning, require은 error
// include './one.php';
// require './one.php';
//중복적으로 include/require 하는것 방지. (한번만 호출)
// include_once './one.php';
// include_once './one.php';
// require_once './one.php';
// require_once './one.php';
?>
둘의 차이점은 파일을 찾을 수 없거나 권한 오류가 날때 warning(include)과 error(require)로 나뉜다는 점이다.
관련글 (Include + Require 에러 처리)
신기한 PHP의 세계
개요 PHP 4.0 └ PHP 3.0 + 프레임워크(Zend 엔진) └ 모듈화 및 웹 서버 인터페이스 부문이 추가되었다. └ 이식성 측면이 상향되었다. PHP 5.0 └ 객체지향 문법이 추가되었다. ( PHP 3.0/4.0 버전에서는 Cla
conative.tistory.com