Skip to Main Content
PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites
book

PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites

by Janet Valade
September 2006
Intermediate to advanced content levelIntermediate to advanced
319 pages
9h 24m
English
Visual
Content preview from PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites

Chapter 5. Reusing PHP Code

Include a Code File

Your Web site scripts may need to perform a task repeatedly, such as displaying the company address or storing data in a database. Efficient development dictates that you write PHP code to perform a certain task and use the same code whenever the task is required.

One method for reusing code is PHP include files. You can store as many lines of code as you need in a file, separate from your script, and insert (called include) the file into the script wherever you need it.

PHP provides four statements for inserting a file into a script: include, include_once, require, and require_once. You can use the following format for all four, passing a string or a variable:

include(path/filename);

The include/require ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

Larry Ullman

Publisher Resources

ISBN: 9780470048399Purchase book