Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2015, Fred McClurg, All Rights.

Similar presentations


Presentation on theme: "Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2015, Fred McClurg, All Rights."— Presentation transcript:

1 Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, frmcclurg@gmail.com © Copyright 2015, Fred McClurg, All Rights Reserved

2 Chapter Five Including Files http://cecert.kirkwood.edu/~fmcclurg/courses/p hp/slides/chapter05c.include.ppt 2

3 Description: Allows you to define functions in a separate file in order to reuse those definitions elsewhere. Similar to the pre-processor #include statement in C, the “include” statement operates just as if you typed in the file contents at the include statement. Syntax: include( 'filename' ); Upon Error Condition: Displays warning message and continues processing. The “include” Statement 3

4 An “include” Example functions.php <?php function add($a, $b) { return($a + $b); } ?> callInclude.php <?php include('functions.php'); echo add( 2, 3 ); ?> 4

5 Description: Behaves similarly to the “include” statement except it does not include files that have been included previously. Syntax: include_once( 'filename' ); Upon Error Condition: Displays warning message and continues processing. The “include_once” Statement 5

6 misc.php <?php function wonderful() {... } ?> db.php <?php include('misc.php'); ?> math.php <?php include('misc.php'); ?> include_once.php <?php include_once(‘math.php’); include_once(‘html.php’); include_once(‘db.php’); ?> The “include_once” Example 6 6 html.php <?php include('misc.php'); ?>

7 Description: Behaves similarly to the “include” statement except in how errors are handled. Syntax: require( 'filename' ); Upon Error Condition: Displays error message and exits. The “require” Statement 7 7

8 Description: Behaves similarly to the “require” statement except it does not include files already included. Syntax: require_once( 'filename' ); Upon Error Condition: Displays error message and exits. The “require_once” Statement 8 8

9 to be continued... http://cecert.kirkwood.edu/~fmcclurg/courses/p hp/slides/chapter06a.numeric.ppt http://cecert.kirkwood.edu/~fmcclurg/courses/p hp/slides/chapter06a.numeric.ppt 9


Download ppt "Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2015, Fred McClurg, All Rights."

Similar presentations


Ads by Google