Download presentation
Presentation is loading. Please wait.
1
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, frmcclurg@gmail.com © Copyright 2010, All Rights Reserved 1
2
Chapter Five Including Files 2 http://webcert.kirkwood.edu/~fmcclurg/c ourses/php/slides/chapter05.include.ppt
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
The “include_once” Example misc.php <?php function wonderful() {... } ?> math.php <?php include('misc.php'); ?> html.php <?php include('misc.php'); ?> db.php <?php include('misc.php'); ?> include_once.php <?php include_once(‘math.php’); include_once(‘html.php’); include_once(‘db.php’); ?> 6
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
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
9
Chapter Five Object Oriented Programming (OOP) 9
10
Definitions: Object: Self contained “thing” or “black box”. Method: Function contained in an object. Attribute: Variable inside of an object. Class: Collection of methods and attributes. Instance: A single object created from a class. Object Oriented Programming (OOP) 10
11
to be continued... http://webcert.kirkwood.edu/~fmcclurg/c ourses/php/slides/chapter06a.numeric.ppt
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.