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 - PHP Tutorial
From the course: PHP for Web Designers
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
What are server-side includes?4m 4s
-
(Locked)
Deciding which include command to use5m 40s
-
(Locked)
Challenge: Moving common elements to include files1m 54s
-
(Locked)
Solution: Moving common elements to include files7m 4s
-
(Locked)
Making sure internal links still work in an include file6m 1s
-
(Locked)
-
-
-
-
-
-