From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Deciding which include command to use

Deciding which include command to use - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Deciding which include command to use

PHP has not only one command for server side includes, but four. Let's take a look at how they differ and what happens when an include file can't be found. The four commands are include, require, include_once, and require_once. They all do basically the same thing. They include the content of an external file, in another page, or in a PHP script. As a web designer the only time you're likely to need include once or require once, is if you're working with a programmer. Redefining a function or class, generates a fatal error in PHP. So the once versions are intended to prevent that from happening in a complex programming environment. So that basically reduces your choice to just the first two, include and require. The difference between them boils down to what happens when the include file can't be found. What include means is, look, I'd really like to include this file, but if you can't find it, just keep going. Require on the other hand, is used in the sense of, look I'm really going…

Contents