logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Painting
Heart Disease
Horror Literature
Dating
Hiking & Backpacking
SF/Fantasy Books
Healthy Foods


dailyclick
All times in EST

Full Schedule
g
g PHP Site

BellaOnline's PHP Editor

g

Personal Activities Calendar Program – Use the PHP include() Statement to Check Input Data

Guest Author - Diane Cipollo

In a previous tutorial, we created the Activity_Entry_Form ( ) function that will print the Activity Entry Form for our Personal Activities Calendar Program. We did this because this section of our code will be used several times in the program. There is another section of code that will be used more than once in our application and this is the code that checks for missing data after the form has been submitted. Because this task is performed several times, we can simplify our program by separating out this section of code as we did with the function. There are other ways to compartmentalize sections of code, for example, you can create a PHP class or simply use the PHP include( ) statement. Because this is a beginner's tutorial, let's discuss the include( ) statement method.

What the PHP include( ) statement says is "get this file and place it right here". Therefore, you will want to place the include( ) statement within your program at the exact stop where you want the included code to be executed.

Let's go back to the ActivityEntry.php3 file and separate out the code that checks for missing data. Now cut and paste that code into a blank file and name that file CheckData.php3. If you take a look at the sample, you will notice that I have not only pasted the section of code from the AcitvityEntry,php3 file but I have also added an opening and closing PHP tag. If I had not added these tags in our new CheckData.php3 file, the code would have been treated as plain text instead of PHP code.

Now all you need to do is put the include statement into the ActivityEntry.php3 file at the place where you removed the code previously.

include ("CheckData.php3");

You will want to put the relative path to the file to be included (CheckData.php3) between the quotation marks. This is called an argument for the include statement. You will also notice that, unlike the function code example, we do not need to use a require_once statement at the top of the file.






This site needs an editor - click to learn more!

Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Twitter Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Facebook Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to MySpace Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Del.icio.us Digg Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Yahoo My Web Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Google Bookmarks Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Stumbleupon Add Personal+Activities+Calendar+Program+%96+Use+the+PHP+include%28%29+Statement+to+Check+Input+Data to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the PHP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2013 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2013 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor