100% found this document useful (3 votes)
15 views56 pages

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane - Download the ebook today and own the complete content

The document provides an overview of various programming resources available for download at textbookfull.com, including titles focused on PHP, MySQL, and algorithms. It features a detailed description of 'A Web-Based Introduction to Programming' by Mike O'Kane, which covers essential programming concepts and languages. Additionally, it lists several other programming-related ebooks and their links for instant download.

Uploaded by

britssurong76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (3 votes)
15 views56 pages

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane - Download the ebook today and own the complete content

The document provides an overview of various programming resources available for download at textbookfull.com, including titles focused on PHP, MySQL, and algorithms. It features a detailed description of 'A Web-Based Introduction to Programming' by Mike O'Kane, which covers essential programming concepts and languages. Additionally, it lists several other programming-related ebooks and their links for instant download.

Uploaded by

britssurong76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 56

Explore the full ebook collection and download it now at textbookfull.

com

A Web Based Introduction to Programming Essential


Algorithms Syntax and Control Structures Using Php
Html and Mariadb MySQL Mike O’Kane

https://textbookfull.com/product/a-web-based-introduction-
to-programming-essential-algorithms-syntax-and-control-
structures-using-php-html-and-mariadb-mysql-mike-okane/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

PHP and MySQL for Dynamic Web Sites Fifth Edition Ullman

https://textbookfull.com/product/php-and-mysql-for-dynamic-web-sites-
fifth-edition-ullman/

textbookfull.com

PHP and MySQL Web Development 5th Edition Developer s


Library Luke Welling

https://textbookfull.com/product/php-and-mysql-web-development-5th-
edition-developer-s-library-luke-welling/

textbookfull.com

Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5


Second Edition Steve Prettyman

https://textbookfull.com/product/learn-php-8-using-mysql-javascript-
css3-and-html5-second-edition-steve-prettyman/

textbookfull.com

Essential algorithms a practical approach to computer


algorithms using Python and C Second Edition Rod Stephens

https://textbookfull.com/product/essential-algorithms-a-practical-
approach-to-computer-algorithms-using-python-and-c-second-edition-rod-
stephens/
textbookfull.com
Beginning PHP and MySQL: From Novice to Professional 5th
Edition Frank M. Kromann

https://textbookfull.com/product/beginning-php-and-mysql-from-novice-
to-professional-5th-edition-frank-m-kromann/

textbookfull.com

Problem Solving in Data Structures Algorithms Using C


Programming Interview Guide First Edition Hemant Jain

https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-first-edition-hemant-
jain/
textbookfull.com

Problem Solving in Data Structures Algorithms Using C


Programming Interview Guide 1st Edition Hemant Jain

https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-1st-edition-hemant-
jain/
textbookfull.com

Learning PHP, MySQL & JavaScript, 6th Edition Robin Nixon

https://textbookfull.com/product/learning-php-mysql-javascript-6th-
edition-robin-nixon/

textbookfull.com

Introduction to Java Programming and Data Structures


Comprehensive Version Y Daniel Liang

https://textbookfull.com/product/introduction-to-java-programming-and-
data-structures-comprehensive-version-y-daniel-liang/

textbookfull.com
A Web-Based Introduction
to Programming

2
A Web-Based Introduction
to Programming

3
Essential Algorithms, Syntax,
and Control Structures Using PHP, HTML,
and MariaDB/MySQL

Fourth Edition

Mike O'Kane

4
Copyright © 2017
Mike O'Kane
All Rights Reserved.

Library of Congress Cataloging-in-Publication Data

Names: O'Kane, Mike, 1953- author.


Title: A web-based introduction to programming : essential algorithms,
syntax, and control structures using PHP, HTML, and MariaDB/MySQL / Mike
O'Kane.
Description: Durham, North Carolina : Carolina Academic Press, [2017] |
Includes bibliographical references and index.
Identifiers: LCCN 2017017694 | ISBN 9781531002749 (alk. paper)
Subjects: LCSH: Computer software--Development. | Internet programming. |
Computer programming--Web-based instruction. | PHP (Computer program
language) | XHTML (Document markup language)
Classification: LCC QA76.76.D47 O43 2017 | DDC 005.3--dc23
LC record available at https://lccn.loc.gov/2017017694

eISBN 978-1-53100-707-2

Carolina Academic Press, LLC


700 Kent Street
Durham, North Carolina 27701
Telephone (919) 489-7486
Fax (919) 493-5668

www.cap-press.com

Printed in the United States of America.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any
means, electronic, mechanical, recording or otherwise, without the prior written permission of the author.

Please note: The information in this book is provided for instructional value and distributed on an “as is” basis,
without warranty. While every precaution has been taken in the preparation of the book, neither the author nor
Carolina Academic Press shall have any liability to any person or entity with respect to any loss or damage caused
by or alleged to be caused, directly or indirectly, by the instructions contained in this book or by the programs or
applications that are listed in, or provided as supplements to, this book.

Macintosh®, Mac OS®, Safari, and iOS® are registered trademarks of Apple, Inc. in the United States and other
countries. Windows® and Windows Mobile® are registered trademarks of Microsoft Corporation in the United
States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other
countries. MySQL® is a registered trademark of Oracle Corporation and/or its affiliates. MariaDB® is a registered
trademark of MariaDB Corporation Ab. Mozilla® and Firefox® are registered trademarks of the Mozilla
Foundation. Joomla!® is trademarked by Open Source Matters. Apache® is a trademark of the Apache Software
Foundation. XAMPP and Apache Friends are registered trademarks of BitRock. The WordPress® trademark is
owned by the WordPress Foundation. Android® and Google Chrome® are trademarks of Google Inc. The Drupal®
trademark is owned and controlled by Dries Buytaert. BlackBerry® is a trademark of Blackberry. All product
names identified in this book are trademarks or registered trademarks, and are the properties of their respective
companies. We have used these names in an editorial fashion only, and to the benefit of the owner, with no

5
intention of infringing the trademark.

6
To my dear mother and father,
thank you for the love and light that you bestowed on us.

7
Contents

Preface
Acknowledgments
About the Author

Chapter 1 · Introducing Computer Programming


Introduction
What Is a Computer Program?
What Do Programmers Do?
The Software Development Life Cycle
The Importance of Writing and Communicating
What Are Programming Languages?
Compilers and Interpreters
So Many Languages!
Standalone and Network Applications
Markup Languages
Combining Markup and Programming Languages
Summary
Chapter 1 Review Questions

Chapter 2 · Client/Server Applications—Getting Started


Introduction
Client/Server Design in Web Applications
Working with Files and Folders
Locating Files and Folders on Computers Running a Windows Operating System
Locating Files and Folders on the Internet
Internet Naming Conventions for Files and Folders
Working with a Local Web Server
What Languages Will I Use?
What Software Will I Need?
Installing a Text Editor
Installing One or More Web Browsers
Installing Your Web Server
Using Your Web Server
Using URLs with Your Web Server
Always Use URLs to Run Your Web Applications!
Where to Save Your Work Files
The Importance of Frequent Backups
Creating an HTML Document
Creating a PHP program

8
Creating an Interactive HTML and PHP Program
Summary
Chapter 2 Review Questions
Chapter 2 Code Exercises

Chapter 3 · Program Design—From Requirements to Algorithms


Introduction
What Are Instructions?
Common Characteristics of Instructions
Sequence, Selection and Repetition Structures
A Programming Example
Creating an Input, Processing, Output (IPO) chart
Designing the User Interface
Developing an Algorithm
A Smoking Calculator
Coding the Application
Summary
Chapter 3 Review Questions
Chapter 3 Code Exercises

Chapter 4 · Basics of Markup—Creating a User Interface with HTML


Introduction
A Short History of HTML
Introducing HTML Tags
Ignoring White Space
More HTML Tags
Introducing HTML Tables
Using HTML Tables to Layout Web Pages
Other HTML Tags
Deprecated HTML Tags
Introducing Style Sheets
Multiple Styles for a Single Tag
Selecting Colors for Fonts and Backgrounds
Referencing a Style Sheet in Your HTML Document
Applying a Style Sheet to Multiple Pages
Interactive User Interfaces
Creating HTML Forms
Using HTML Forms to Obtain User Input
Using HTML Tables to Line Up Prompt and Input Boxes
Problems with Form Submission
Drop Down Lists
Combining Textboxes and Drop Down Lists
Other Types of Input
Stylesheets and Forms

9
Summary
Chapter 4 Review Questions
Chapter 4 Code Exercises

Chapter 5 · Creating a Working Program—Basics of PHP


Introduction
Why PHP?
Working with HTML and PHP
Important Features of Client/Server Programs
Receiving Input from a Form — wage2.php
Processing the Smoking Survey — smoking.php
PHP — General Guidelines and Syntax
Arithmetic Expressions
Using Arithmetic Functions
White Space in PHP Files
Generating Character Strings from PHP
Including Double Quotes in Character Strings
Using Multiple PHP Sections
Using the number_format() Function to Display Numbers to a Specific Number of Places
Including Calls to PHP Functions inside PHP Print Statements
String Concatenation and the Concatenation Operator
The PHP Echo Statement
Finding Syntax Errors
Finding Logical Errors
Summary
Chapter 5 Review Questions
Chapter 5 Code Exercises

Chapter 6 · Persistence — Saving and Retrieving Data


Introduction
The Difference Between Persistent and Transient Data
Files and Databases
Working with a Text File
Closing a Text File
Reading Data from a Text File
PHP Functions to Read Data from a Text File
Writing Data to a Text File
PHP Functions to Write Data to a Text File
Be Careful to Avoid Security Holes!
Using Escape Characters
Escape Characters and HTML Tags
Using PHP to Append Data to Files
PHP Functions to Append Data to a Text File
Processing Files that Contain Complete Records on Each Line

10
PHP Functions to Parse a Delimited Character String
Processing a File with Multiple Records
Appending Records to a File
Working with Multiple Files
Summary
Chapter 6 Review Questions
Chapter 6 Code Exercises

Chapter 7 · Programs that Choose — Introducing Selection Structures


Introduction
Introducing IF and IF..ELSE Structures
Introducing Flow Charts
Boolean Expressions and Relational Operators
Selection Using the IF Structure
Testing Threshold Values
Selection Using the IF..ELSE Structure
When to Use Braces in IF..ELSE Statements
Creating a Program with Multiple but Independent Selection Structures
Comparing Strings — Testing for a Correct Password
Ignoring the Case of a Character String
Providing a Selective Response
Using Selection to Construct a Line of Output
Summary
Chapter 7 Review Questions
Chapter 7 Code Exercises

Chapter 8 · Multiple Selection, Nesting, ANDs and ORs


Introduction
Introducing the Logical Operators AND and OR
Introducing the NOT Operator
Validating User Input
Using A Nested Selection Structure to Validate Input
Designing Applications with Nested Selection Structures
Use of Braces in Nested Selection Structures
Chaining Related Selection Structures
Additional Input Validation Using Chained Selection Structures
More about Input Validation: Using the trim() Function
When to Use AND or OR? Be Careful with Your Logic!
The Challenge of Software Testing
A Special Case: The Switch Statement
More Examples in the Samples Folder
Some Words of Encouragement
Summary
Chapter 8 Review Questions

11
Chapter 8 Code Exercises

Chapter 9 · Programs that Count — Harnessing the Power of Repetition


Introduction
Controlling a Loop by Counting
Coding a FOR Loop in PHP
General Syntax of a FOR Loop
Including the Counting Variable in Your Loop Statements
Using a Variable to Control the Loop Condition
Converting from Celsius to Fahrenheit
Changing the Increment Value
Using Loops with HTML Tables
Allowing the User to Control the Loop
Improving Processing Efficiency
Using Loops to “Crunch Numbers”
Using a Loop to Accumulate a Total
Finding the Total and Average from a File of Numbers
Finding the Highest and Lowest Values in a Series
Performing Multiple Operations on a File of Numbers
Nesting IF..ELSE Structures to Customize Output from a Loop
Loops within Loops — Creating a Bar Chart
Selecting from a List of Data Files
Summary
Chapter 9 Review Questions
Chapter 9 Code Exercises

Chapter 10 · “While NOT End-Of-File”—Introducing Event-Controlled Loops


Introduction
Characteristics of WHILE Loops
The Structure of WHILE Loops
An Algorithm to Process Files of Unknown Length
Using a WHILE Loop to Process a File of Scores
Including Selection Structures Inside a WHILE Loop
Using a WHILE Loop to Count, Sum and Average Data
Using a WHILE Loop to Process a File of Records
Processing Weekly Wages from a File of Timesheet Records
Processing Selected Records from a File of Timesheet Records
Processing Selected Fields from a File of Records
Processing a File of Survey Data
Using DO..WHILE or REPEAT..UNTIL Loops
Summary
Chapter 10 Review Questions
Chapter 10 Code Exercises

12
Chapter 11 · Structured Data — Working with Arrays
Introduction
What Is an Array?
Working with Array Elements
Extending an Array
Displaying Array Values
Receiving Scores into an Array from an HTML Form
Arrays of Strings
How Large Is the Array?
Why Do Array Indices Begin with 0 and Not 1?
Using FOR Loops with Arrays
Using the sizeof() Function to Control a FOR Loop
Summing and Averaging the Values in an Array
Counting Selected Values in an Array
Multiple Operations on an Array
Reading Data from a File into an Array
Reading Data into an Array from a File of Unknown Length
Using [] with no Index Value
Reading Selected Data from a File into an Array
Reading Data from a File into Multiple Arrays
Reading Selected Data from a File of Records into an Array
More About the explode() and list() Functions
A Special Loop for Processing Arrays — FOREACH
Multi-Dimensional Arrays
Summary
Chapter 11 Review Questions
Chapter 11 Code Exercises

Chapter 12 · Associative Arrays


Introduction
Using a Variable to Reference the Key of an Associative Array
Using Associative Arrays as Lookups
Using the array() Function to Create Associative Arrays
Associative Arrays and the FOREACH Loop
More about the $_POST Array
Using the isset() Function to Combine a Web Form with the Form Processing Code in a Single Page
Web Sessions and the $_SESSION Array
Adding Code to Manage a Web Session
Creating, Initializing and Modifying Session Variables
Validating $_SESSION and $_POST Arrays
Revisiting the Same Page in a Web Session
Summary
Chapter 12 Review Questions

13
Chapter 12 Code Exercises

Chapter 13 · Program Modularity — Working with Functions


Introduction
Using Functions
Understanding Function Arguments
Receiving Values from a Function
Researching Available Functions
Reasons to Use Pre-Defined Functions
Using die() or exit() to Terminate an Application
Creating Your Own Functions
Where Do I Put My Functions?
Creating a Library of Functions
Including Functions from External Files
Using the Same Functions in Different Programs
Functions Calling Functions
Learning to Think Beyond Specific Applications
More about Include Files
Summary
Chapter 13 Review Questions
Chapter 13 Code Exercises

Chapter 14 · Connecting to a Database — Working with MySQL


Introduction
What Is a Relational Database?
The Relational Database Management System (RDBMS)
Structured Query Language — MySQL
Starting Your MySQL Server
Configuring MySQL for Use with This Textbook
Three Ways to Work with MySQL
Working with PHP and MySQL
Using PHP to Open and Close a Connection to a MySQL Server
Using the MySQL SELECT Query
Selecting Specific Records
Relational Operators in MySQL
The Logical Operators AND and OR
Ordering Your Query Results
Viewing Your Query Results
Using an HTML Table to Display the Query Results
Putting It All Together
Using Input from an HTML Form to Construct a Query
Processing Queries with a Single Result
Performing Calculations with the Result Set
Performing Aggregate Operations on MySQL Queries

14
Performing JOIN Operations on Multiple Tables
Using INSERT to Add Records to a Table
Using UPDATE to Modify a Record
Removing a Record
Storing MySQL Connection Data in an Include File
Creating, Dropping, and Altering Databases and Tables
Summary
Chapter 14 Review Questions
Chapter 14 Code Exercises

Chapter 15 · Introduction to Object-Oriented Programming


Introduction
What is an Object?
Creating and Using Instances of a Class
Using Employee Objects in an Application
Defining an Object
Coding the Object Class
Creating and Using Instances of an Object Class
The Class Constructor Method
Method Overloading
Why do Objects Matter?
Object Design and Inheritance
Abstract Classes and Methods
Method Over-riding
Polymorphism
OOP and Databases
OOP Development
OOP Languages
Summary
Chapter 15 Review Questions
Chapter 15 Code Exercises

Chapter 16 · Where to Go from Here . . .


Introduction
Moving Forward with PHP and HTML
More about PHP
PHP and Other Languages
XHTML and XML
Client Side Processing with Javascript and Ajax
The Importance of OOP
IDE's, Modeling Languages and Frameworks
Client/Server and Server/Server Programming
Mobile Applications
Digital Media

15
Graphical User Interfaces and Interface Design
Web Design and Content Management
Database Programming and SQL
In Summary: Follow Your Heart!

Appendix A · Data Representation and Formats


Introduction
Storing Data in Bits and Bytes
How Multimedia Data Is Represented in Binary
How Numeric Values Are Represented in Binary
How Plain Text Is Represented in Binary
How Source Code and Markup Code Is Represented in Binary
How Program Instructions Are Represented in Binary
How Memory Addresses Are Represented in Binary
What Else Can Be Represented in Binary?

Appendix B · Files, Folders, Addressing Schemes, and Command Line Arguments


File Types and File Extensions
Disk and Disk Drives
Files and File Folders (Directories)
Naming Files and Folders
File Addresses in Windows and on the Web
Relative Addresses in Windows
Relative Addresses on the Internet
Using Relative Web Addresses in HTML Code
Managing Files at the Command Line
Introduction to MS DOS Commands
Recalling Previous Commands
Use Double Quotes when Paths Include Spaces
Printing the Contents of the Console Window
Creating Batch Files
Unix Commands

Appendix C · Installing and Running Your Standalone Web Server


Using an Active Web Server
Problems Using Your Web Server
Advanced Users

Appendix D · Debugging Your Code


Problems Viewing Your HTML or PHP Programs
Problems with HTML Layout
Locating PHP Syntax Errors
Common PHP Syntax Errors
Common Logical Errors

16
Appendix E · More about HTML and CSS
Useful HTML References
Useful CSS References
Inline Styles and Internal Style Sheets
Deprecated HTML Tags
Frequently Asked Questions Regarding HTML Tags

Appendix F · More about PHP Functions and Data Types


Useful PHP References
More about PHP Functions and Data Types
Standard PHP Array Functions
Standard PHP File Functions
Standard PHP Math Functions
Standard PHP String Functions
PHP Data Types

Appendix G · Additional PHP Operators and Control Structures


Shortcut Operators
Switch Structure
Another Loop Structure: DO..WHILE
Multi-Dimensional Arrays
Ragged Arrays
Multi-Dimensional Associative Arrays

Index

17
Preface

The problem I have tried to solve with this textbook is, quite simply, how to effectively introduce general
programming concepts to students who have never programmed before. Perhaps like me, you have found yourself
frustrated by textbooks that try to cover too much too fast, make inappropriate assumptions about what a student
already knows, or take sudden leaps in complexity when providing examples and exercises.
I believe that the purpose of an introductory programming course is to help students gain confidence and
develop their understanding of basic logic, syntax, and problem-solving. They do not need to learn all aspects of a
language or even learn best practices—these are topics for the next course level. The question is: how to provide
the kind of hands-on experience that supports active learning without overwhelming the beginning student with
too much syntactical and programmatic detail?
I have tried many approaches over the years before settling on a Web-based approach, using PHP, CSS, and
HTML code to develop small, interactive Web applications. This approach has proved very successful. Many
students report how much they enjoy the course, how much they have learned, and how well the material has
served them in subsequent courses and in their professional life. I also hear from many students who tell me that
the course positively changed their opinion of programming as a career or subject of interest, which is most
gratifying.
Some instructors may have concerns that my coverage of the PHP and HTML is insufficient. The book uses a
small number of HTML tags, CSS rules, and PHP functions, and employs some arbitrary conventions to simplify
the code and keep the focus on basic concepts common to most languages. For example, PHP print statements
are used rather than echo statements, and these statements always include parentheses and double quotes so that
the syntax is more consistent with the output statements of most other languages. The last chapter (“Where to Go
From Here”) clarifies which practices are standard and which are particular to the textbook.

18
Intended Audience
The book is designed to serve:

Instructors teaching introductory programming, programming logic and design, or Web programming
courses, who want a textbook that engages students and provides a solid preparation for subsequent courses,
but avoids overwhelming beginners with too much syntactical detail or program complexity.
Traditional and online students taking a first course in programming, programming logic and design, or
Web programming.
Web designers, graphic artists, technical communicators, and others who find that their work increasingly
requires some degree of programming expertise, and need an effective, hands-on introduction.
Others who wish to learn the basics of programming, either for personal interest, or to explore the
possibility of a career in this field.

Note that solutions to quizzes and exercises are only available to verified course instructors.

19
Approach
The book takes a fairly novel approach, allowing students to learn program logic and design by developing a large
number of small Web-based applications. Students love working with the Web, and this approach has other
important benefits:

Important concepts such as client/server design, server-side processing, and interface-driven code modules
can be introduced in the form of working applications, and then applied in hands-on exercises.
Students not only learn the essential control structures and syntax of a programming language, but also learn
to use a markup language (and associated style sheets), and a database query language to access and query a
database. This makes sense in today's programming environment where these languages are routinely used
in combination to develop a networked application.
The material is relevant to students across a range of disciplines: Computer Science, Information Systems,
Technical Communications, Network Systems, Digital Media, Web Technologies, Mobile Applications,
Database Programming, and other technology-related fields.
The focus on hands-on problem-solving and fundamental structures prepare students for next-level,
language-specific courses such as PHP, Python, Java or C++, as well as Web design and database courses,
without replicating a great deal of material, while the syntax covered here is generally consistent with these
and other languages.

The book makes use of a programming language (PHP), a scripting language (HTML), a style sheet language
(CSS), and a database query language (MariaDB or MySQL), but does not attempt to provide a complete
overview of these languages. Instead, students learn sufficient syntax to convert requirements into working
applications using basic programming structures, arithmetic and logical expressions, user interfaces, functions,
data files, and SQL queries. The focus remains on basic concepts, logic and design, algorithm development, and
common programming procedures. The book provides context throughout, explaining why each topic is
important, and referring students to related career paths.
Although the book focuses on Web-based applications, there is NO requirement for a network-based
programming environment. The book uses a fully functional but standalone Apache Web server (the open source
xampp distribution provided by the Apache Friends group) that students can install on a USB drive or home
computer simply by unzipping a file. Students can begin programming in HTML, PHP and MariaDB or
MySQL in literally minutes.

20
Features
Each chapter begins with clearly stated learning outcomes. Each topic is introduced using examples of simple
program requirements that are first developed as algorithms and interfaces and then realized in working code.
Code statements and control structures are explained step by step.
Different programming topics are treated in separate chapters. Even topics that are commonly combined, such
as counting loops and event-controlled loops, have their own chapters so that students have the chance to develop
and apply their understanding of each separately.
Each chapter includes quizzes that have been carefully developed to test the student's understanding of the
chapter's learning outcomes. The questions have been tested extensively in the classroom.
Three different types of coding exercise are provided at the end of each chapter:

Fixit exercises provide small programs that include a single error of some kind. These exercises help students
improve their problem-solving ability, test their understanding of key concepts, and develop tracing and
debugging skills.
Modify exercises provide working programs that must be modified to perform a somewhat different or
additional function. These exercises help students determine how and where to add new code, and test their
ability to read and understand existing code.
Code completion exercises allow students to apply concepts and tools covered in the chapter by developing
new applications. These exercises test the student's ability to: understand requirements, develop algorithms,
and produce working code. The code completion exercises follow consistent themes that are developed
throughout the book, so that students can more readily appreciate the value of new functionalities that they
learn in each chapter.

Templates for each exercise contain partially completed code so students don't waste time typing (and debugging)
code that is not relevant to the problem at hand. The templates also help instructors to streamline the grading
process.
The textbook comes with a standalone Web server that can be installed on a fixed or portable drive simply by
unzipping a file (so students can bring the software with them to work on computers at any location).
The server installation includes textbook folders that contain all code samples and exercise templates. Students
can complete the exercises simply by opening, editing, and saving the appropriate files. Assignments can be turned
in simply by zipping and submitting the appropriate chapter folder.
The textbook appendices provide additional learning resources designed to: (a) help individual students with
particular needs or interests (for example file/folder management, additional references, and help debugging
code); and (b) deliver useful topics not included in the chapters (for example data representation, additional
control structures, and multi-dimensional arrays).

21
Textbook Web Site
The textbook Web site ensures that both students and instructors have access to the most current resources
associated with this textbook. The Web site includes: everything you need to install and use the Web server; slide
presentations; and hints and help for students working through each chapter. The Web site also provides support
for verified instructors, including additional exercises, test banks, slide presentations, quiz solutions, code
solutions, and other instructional resources. The Web site can be found at:
http://www.mikeokane.com/textbooks/WebTech/

22
Changes to the Fourth Edition
In addition to minor corrections and improvements, this fourth edition of the book includes: a new install of the
xampp Apache Web server distribution with installation instructions for Windows, Mac OS, and Linux; revised
file naming conventions that are more standard for current web development; a hopefully improved redesign of
Chapters 7 and 8; additional materials and improvements to Chapter 13 (functions); references to both MySQL
and MariaDB in Chapter 14 (the actual code and descriptions are identical); a new Chapter 15 that introduces
Object-Oriented Programming.

23
Chapter Overview
Chapter 1: Introducing Computer Programming. Students learn the relationship between machine language
and high-level languages, and review common tasks that computer programs typically perform. The work of a
programmer is described, and the software development cycle is explained. The chapter highlights and briefly
summarizes design approaches such as algorithm development, interface design, client/server design and object-
oriented programming. Different programming languages are identified, and the distinction is made between
interpreted and compiled languages, and between markup and programming languages. Standalone and network
applications are also contrasted.
Chapter 2: Client/Server Applications—Getting Started. This chapter prepares students for the hands-on
work they will perform in subsequent chapters. File types and local and Internet addressing schemes are explained.
Instructions are provided to install, run, and test the required software. Students are shown how to create, store,
and run a number of sample applications in order to become familiar with the process of using a text editor,
saving files, running the Web server, and viewing the results in a Web browser.
Chapter 3: Program Design—from Requirements to Algorithms. The general characteristics and
requirements of effective instructions are explored, using human and program examples. Students walk through
the process of reviewing simple requirements, creating input, processing, and output (IPO) charts, designing the
interface, and developing solution algorithms. The chapter introduces sequence, selection and control structures,
variables and assignment operations, and arithmetic and logical expressions.
Chapter 4: Basics of Markup—Creating a User Interface with HTML. This chapter explains the significance
of data rendering, and provides a brief overview and history of Hypertext Markup Language (HTML).
Commonly used HTML tags are explained, and the student is shown how to apply these to create and organize
simple Web pages. Cascading style sheets are introduced. Students are shown how to create HTML forms to
obtain user input as a first step in developing interactive Web applications. HTML Tables are used to perform
simple form layout.
Chapter 5: Creating a Working Program—Basics of PHP. This chapter teaches sufficient PHP language
syntax to process user input received from HTML forms, perform simple arithmetic, and produce formatted
output. In the process, students learn to code arithmetic expressions, use standard operators and functions, create
and work with variables, and identify and fix both syntax and logical errors.
Chapter 6: Persistence—Saving and Retrieving Data. This chapter explains the difference between persistent
and transient data, and introduces text file processing as well as basic database concepts. Students learn to: open,
read, write, and close text files; work with multiple files; parse lines of data that contain multiple values separated
by some kind of delimiter.
Chapter 7: Programs that Choose—Introducing Selection Structures. This chapter introduces selection
control structures and demonstrates the use of algorithms to solve problems requiring simple selection. Students
learn to use IF and IF..ELSE structures, Boolean expressions, relational operators, truth tables, simple string
comparisons, and testing procedures.
Chapter 8: Multiple Selection, Nesting, ANDs and ORs. This chapter develops examples from Chapter 7 to
handle problems associated with input validation and more complex requirements. Students explore the use of
compound Boolean expressions, nested selection structures, chained IF..ELSEIF..ELSE selection structures, and
multiple but independent selection structures.
Chapter 9: Programs that Count—Harnessing the Power of Repetition. This chapter introduces loop
structures with a focus on count-controlled FOR loops. Students learn how to refer to the counting variable
within the loop, and how to use loops to generate tables, crunch numbers, accumulate totals, find highest and
lowest values in a series, select values from a file of records, and display bar charts.
Chapter 10: “While NOT End-Of-File”—Introducing Event-Controlled Loops. This chapter introduces
WHILE loops and demonstrates the use of the priming read and the standard algorithm to process files of
unknown length. The student is shown how WHILE loops can be used to perform various operations on a list of

24
data values, and how a file of records can be processed and searched for specific records or field values.
Chapter 11: Structured Data—Working with Arrays. This chapter introduces numerically-indexed arrays,
and shows how arrays can be used to store, access, and update multiple-related values. The use of the FOR loop
to process arrays is explained, and various array-processing algorithms are demonstrated.
Chapter 12: Associative Arrays. This chapter introduces associative arrays. Students learn how to use
associative arrays as lookups, and gain a better understanding of the $_POST array and the way that data is
received from HTML forms. Web sessions are introduced, and students learn how to use the $_SESSION array
to maintain session data between applications.
Chapter 13: Program Modularity—Working with Functions. This chapter demonstrates the importance of
program modularity and introduces functions, include files and objects. Students learn to write their own
functions, to build libraries of related functions, and to call functions from different applications as needed.
Chapter 14: Connecting to a Database—Working with MySQL. This chapter introduces databases queries
as an important application tool. The relationship between relational databases and SQL is explained, along with
the purpose and syntax of common queries (SELECT, INSERT, UPDATE and DELETE). Students learn to
write code to open and close database connections, submit queries, handle errors, perform simple joins, and
process results.
Chapter 15: Introduction to Object-Oriented Programming. This chapter introduces Object-Oriented
Programming. Examples show how simple object classes are designed, how class variables are encapsulated and
accessed by class methods, how objects are instantiated and used in applications, and how classes can be inherited
by other classes. An overview of basic OO terminology is provided.
Chapter 16: Where to Go From Here. This last chapter provides a short overview of key concepts and
technologies that the students may want to explore after completing this textbook, along with clarification of
some of the conventions followed in the book.
The textbook also includes a number of useful appendices as follows:
Appendix A introduces data representation, and shows how binary values can store data for a wide range of
purposes.
Appendix B provides an introduction to overview of file and folder management, file addressing schemes
(including relative and absolute addresses), and the use of the command line with a list of common DOS and
Unix command equivalents.
Appendix C provides help for students wishing to use different Web server installations.
Appendix D provides debugging help for students having trouble identifying and resolving PHP code errors.
Appendix E provides additional material and references for students wishing to learn more about HTML and
style sheets.
Appendix F provides additional information regarding PHP data types, and provides a list of common PHP
functions not covered in the book.
Appendix G provides additional coverage of common PHP operators and structures that were omitted from
the chapters to avoid overwhelming the beginning student (for example, shortcut operators, the SWITCH
statement, DO..WHILE loops, and multi-dimensional arrays).

25
Acknowledgments

This textbook could not have been created without the generous help and support of many others. In particular I
want to thank my dear wife Constance Humphries for her invaluable technical advice, proof-reading,
development of video tutorials, and daily encouragement and patience! My sincere thanks to Scott Sipe, Beth
Hall, Sara Hjelt, and all at Carolina Academic Press for their supportive style, professionalism and experience.
Thanks to all my fellow instructors at A-B Tech (Asheville-Buncombe Technical Community College), especially
to Charlie Wallin and Fred Smartt who field-tested the first edition, and provided invaluable suggestions and
corrections. And thanks to all of those students who have learned with me and sometimes in spite of me as this
book evolved in the classroom. A particular thank you to A-B Tech students Uma Benson, Jean-Jacques Maury,
and Kenneth Stanley, who all voluntarily provided me with carefully compiled lists of corrections that were
incorporated into the fourth edition. Their engagement with the material and concern for future students is
greatly appreciated. Any remaining errors or inconsistencies are of course my own.
Lastly, a huge thank you to Kai ‘Oswald’ Seidler, Kay Vogelgesang, and all those who have contributed to the
Apache Friends Project, and who continue to deliver and support the XAMPP distribution. So many of us owe
you our great appreciation for your generosity of spirit!

26
About the Author

Mike O'Kane holds a master's degree in Systems Science (specializing in Advanced Technology) from
Binghamton University. He has over eighteen years' experience teaching computer science courses, most recently
at Asheville-Buncombe Technical Community College in North Carolina. He also has extensive practical
experience in the use of technology for learning, having worked at IBM as a short-course developer, NC State
University as an Instructional Coordinator, and the University of North Carolina system as the first Executive
Director of the UNC Teaching and Learning with Technology Collaborative. He has a passion for developing
effective instructional content, and learning environments that promote rather than hinder student learning.

27
Chapter 1

Introducing Computer Programming

Intended Learning Outcomes


After completing this chapter, you should be able to:

Explain the difference between computers and other machines.


escribe the purpose of the microprocessor's instruction set.
Explain the relationship between the instruction set and machine language.
List some common tasks that computer programs perform.
escribe what programmers do.
Summarize the stages of the software development cycle.
Explain the importance of writing and communications for programmers.
Explain the relationship between high-level programming languages and machine language.
istinguish between the purpose of a compiler and an interpreter.
Explain the difference between standalone and network applications.
Explain the difference between programming languages and markup languages.

28
Introduction
Welcome! If you have never programmed before, this book is for you. By the time you complete the chapters and
exercises, you will have a good grasp of the basic logic and design of computer programs. The book is designed to
teach common programming syntax and control structures in a manner that will prepare you for further study in
this field, and provide you with sufficient expertise to develop small, interactive Web applications, using a
combination of the HTML markup language and PHP programming language. You will also be introduced to
the CSS stylesheet language, and the MariaDB and MySQL database languages.
To get started, in this first chapter we will explore the general process of programming and define some
important term and practices. For a book that is supposed to be hands-on this chapter is mostly descriptive! Don't
be too concerned if some of the topics don't make complete sense yet. Your understanding will deepen as you
work through the chapters and develop your own applications.

29
Discovering Diverse Content Through
Random Scribd Documents
CHAPTER XXVI.
Introduces Two Celebrities.
What a change a short half-hour may make in the position and
feelings of any person! Little did Ben imagine, when he set out on a
drive in the morning with Major Grafton, that he was on his way to
one of the most hopeless of prisons.
It was hard even now for him to realize his position. He looked from
the window, and with a glance of envy saw in a field, not far away,
some Swiss peasants at work. They were humble people, living a
quiet, uneventful, laborious life; yet Ben felt that they were infinitely
better off than he, provided he were doomed to pass the remainder
of his life in this refuge. But of this he would not entertain the idea.
He was young, not yet seventeen, and life was full of pleasant
possibilities.
"I am a Yankee," he thought, "and I don't believe they will succeed
in keeping me here long. I will keep a bright lookout for a chance to
escape."
Half an hour later Ben heard the key grate in the lock, and, fixing his
eyes on the entrance, he saw Francois enter.
"Monsieur, dinner is ready," he said.
Ben, notwithstanding his disagreeable situation, felt that he, too,
was ready for the dinner. He was glad to find that it was not to be
served to him in his own room. He would have a chance of seeing
the other inmates of the house.
"Where is it?" he asked.
"Follow me," answered Francois, of course in French.
He led the way, and Ben followed him into a lower room, long and
narrow, which was used as the dining-room. There were no side-
windows, and it would have been quite dark but for a narrow strip of
window near the ceiling.
Around a plain table sat a curious collection of persons. It was easy
to see that something was the matter with them, for I do not wish to
have it understood that all the inmates of the house were, like our
hero, perfectly sane. M. Bourdon was not wholly a quack, but he
was fond of money, and, looking through the eyes of self-interest, he
was willing to consider Ben insane, although he knew very well that
he was as rational as himself.
"Sit here, monsieur," said Francois.
Ben took the seat indicated, and naturally turned to survey his
immediate neighbors.
The one on the right-hand was a tall, venerable-looking man, with
white hair and a flowing beard, whose manner showed the most
perfect decorum. The other was a thin, dark-complexioned man, of
bilious aspect, and shifty, evasive eyes. Neither noticed Ben at first,
as the dinner appeared to engross their first attention. This
consisted of a thin broth and a section of a loaf of coarse bread as
the first course. Ben had been accustomed to more luxurious fare,
and he was rather surprised to see with what enjoyment his
neighbors partook of it. Next came a plate of meat, and this was
followed by a small portion of grapes. There was nothing more. It
was clear that M. Bourdon did not consider rich fare good for his
patients.
"I think I would rather dine at the hotel," thought Ben; but the diet
was not by any means the worst thing of which he complained.
"If I were free I would not mind how poor and plain my fare was,"
he thought.
His companions finished dinner before him, and had leisure to
bestow some attention upon him.
"My little gentleman, do you come from Rome?" asked the venerable
old gentleman on his right.
"No, sir," answered Ben.
"I am sorry. I wished to ask you a question."
"Indeed, sir. Perhaps I might answer it even now. I have been in
Florence."
"No; that will not do; and yet, perhaps you may have met persons
coming from Rome?"
"I did, monsieur."
"Then perhaps they told you how things were going on."
"Very well, I believe, monsieur."
"No, that could not be," said the old gentleman, shaking his head. "I
am sure nothing would go well without me."
"Do you, then, live in Rome?" asked Ben, curiously.
"Surely!" exclaimed the old man. "Did you not know that the Pope
lived in Rome?"
"But what has that to do with you, sir?"
"A great deal. Know, my little gentleman, that I—to whom you are
speaking—am the Pope."
This was said with an air of importance.
"There's no doubt about his being insane," thought Ben.
"How, then, do you happen to be here?" asked our hero, interested
to see what his companion would say.
"I was abducted," said the old gentleman, lowering his voice, "by an
emissary of the King of America. M. Bourdon is a cousin of the king,
and he is in the plot. But they won't keep me here long."
"I hope not," said Ben, politely.
"The King of Spain has promised to send an army to deliver me. I
only received his letter last week. You will not tell M. Bourdon, will
you?"
"Certainly not," answered Ben.
"It is well; I thought I could rely upon your honor."
"My friend," said another voice, that of his left-hand neighbor, "you
are losing your time in talking with that old fool. The fact is, he isn't
right here," and he touched his head.
The Pope appeared deeply absorbed in thought, and did not hear
this complimentary remark.
"He thinks he is the Pope. He is no more the Pope than I am."
Ben nodded non-committally.
"He ought to be here. But I—I am the victim of an infamous horde
of enemies, who have placed me here."
"Why should they do that, sir?"
"To keep me out of my rights. It is the English Government that has
done it. Of course, you know who I am."
"No, sir, I don't think I do."
"Look well at me!" and the dark man threw himself back in his chair
for inspection.
"I am afraid I don't recognize you, monsieur," said Ben.
"Bah! where are your eyes?" said the other, contemptuously. "I am
Napoleon Bonaparte!"
"But I thought you died at St. Helena," said Ben.
"Quite a mistake, I assure you. The English Government so asserted,
but it was a deception. They wished my memory to die out among
my faithful French. They buried my effigy, but smuggled me off in a
vessel late at night. They placed me here, and here they mean to
keep me—if they can. But some day I shall escape; I shall re-enter
France; I shall summon all to my banner, and at the head of a great
army I shall enter Paris. Do you know what I will do then?"
"What will you do, sir?" asked Ben, with some curiosity.
"I shall descend upon England with an army of five millions of men,"
said the dark man, his eyes flashing, "and burn all her cities and
towns."
"That will be rather severe, won't it?" asked Ben.
"She deserves it; but I may do worse."
"How can that be?"
"Do you see that man over on the other side of the table—the short,
red-haired man?"
"Yes, I see him."
"He is a chemist and has invented a compound a thousand times
more powerful than dynamite. I am negotiating for it, and, if I
succeed, I mean to blow the whole island out of the water. What do
you think of that, eh?" he continued, triumphantly.
"I think in that case I shall keep away from England," answered Ben,
keeping as straight a face as he could.
"Ah, you will do well."
When dinner was over, the boarders passed out of the room, Ben
among them. He was destined not to go out quietly.
Suddenly a wild-looking woman darted toward him and threw her
arms around his neck, exclaiming:
"At last I have found you, my son, my son!"
Ben struggled to release himself, assisted by Francois, who did not
scruple to use considerable force.
"None of your tricks, madam!" he cried, angrily.
"Will you take from me my boy?" she exclaimed, piteously.
"There is some mistake. I am not your son," said Ben.
The woman shook her head sadly.
"He disowns his poor mother," she said, mournfully.
On the whole, Ben was rather glad to return to his chamber.
"I don't like my fellow-boarders," he thought. "I sha'n't stay in the
maison de fous any longer than I am obliged to."
CHAPTER XXVII.
A Midnight Escape.
For three days Ben passed a dull, uniform existence, being most of
the time confined to his chamber. To a boy of active temperament it
was most irksome. If he only had something to read, the hours
would pass more swiftly. Fortunately, on the second day, he
bethought himself of Francois, who seemed friendly.
"Francois," he said, "can't you get me something to read?"
"I don't know," said the attendant, doubtfully. "What would monsieur
like?"
"Anything you can find. I would prefer a story."
"I will try, monsieur."
The next time Francois made his appearance he held in his hand a
tattered edition of a popular novel.
"Will that do?" he asked.
Ben had never heard of the book, but on opening its pages it looked
attractive, and he answered:
"Yes, Francois, I am much obliged to you."
He thought it politic, remembering that he might need other favors,
to put a franc piece into the hand of the friendly attendant.
Francois brightened up. His wages were so small that these little
gratuities were very welcome.
"Would monsieur like something else?" he inquired.
"There is one thing I would like very much, Francois," answered Ben.
"What is that, monsieur?"
"To get out of this place."
"But monsieur is insane."
"I am no more insane than you are. Do I look insane?"
"No; but one cannot always tell."
"I would give a hundred francs to any one who would get me out of
this," said Ben, not, however, expecting to produce much impression
on the mind of his auditor.
"A hundred francs!" repeated Francois, his eyes sparkling.
But in a moment he looked sober.
"It would not do. I should be discharged," he said.
"Think it over, Francois," said Ben.
The attendant did not answer, but the suggestion had borne fruit.
It may be asked how Ben had so much money. It may be explained
that he was about to send a remittance home, having received a
payment from Major Grafton, but his unexpected arrival at the
refuge had prevented him. He had with him two hundred francs, or
about forty dollars in gold.
Something happened on the third day which worked favorably for
Ben's hopes of securing the active assistance of Francois. About
dusk a boy appeared at the gate of the asylum, and asked to see
Francois.
When the two were brought together, he said:
"I came from your wife. She wishes you to come home. The child—
little Marie—is very sick."
Poor Francois was much disturbed. In a little cottage five miles away
lived his wife and his only child, Marie. The poor fellow was deeply
attached to his child, for it must be remembered that the poor and
simple-minded are quite as apt to have as strong affections as the
richer and more favored.
"Is she very bad, Jean?" he asked, quite pale.
"Yes," answered Jean. "I think she is out of her head. She keeps
moaning. Her poor mother is very much frightened."
"I will ask if I can come," said Francois, and he straightway sought
out the doctor.
"I would like to speak to you, M. Bourdon," he said.
"Speak quick, then, for I am busy," said the doctor, gruffly, for
something had happened to disturb him.
"Jean Gault has just told me that my little Marie is very sick, and my
wife wants me to come home. If I could go now, I would come back
in the morning."
"Well, you can't go," said the doctor, harshly.
"But, Monsieur le Docteur, do you understand that my child—my
little Marie—is very sick? She moans, and is out of her head, and I
may never see her again, if I don't go."
"Plague take your little Marie!" said M. Bourdon, brutally. "What have
I to do with her? I want you to stay here. You know very well that
you can't be spared."
"But," protested Francois, indignantly, "do you think because I am
poor that I have no feeling? You are very much mistaken. I cannot
stay away and let poor Marie die without seeing her."
"You can't go, at all events," said M. Bourdon, roughly.
"I cannot go?"
"No; or, if you do, you will lose your place. I cannot have my men
going away on every silly pretext. I don't believe your child is sick at
all."
"But Jean Gault is below. He has brought word from my wife."
"I dare say it is all planned between you."
"Then you will not let me go?"
"No, I won't. If you go, you lose your place. I shall not take you
back. Do you understand?"
"Yes, I understand," said Francois, slowly.
"Then you can go. We have had words enough about this."
If the doctor had not been irritated he would have been careful how
he dealt with Francois, who was the most valuable man in his
employ. But when we are irritated we lose sight of what is politic,
and are apt to make grievous mistakes, as M. Bourdon certainly did
on this occasion.
Francois sought out little Jean.
"Jean," he said, "go home and tell my wife that I will come some
time to-night. The doctor has forbidden me to go, but I shall go, all
the same. Be sure you tell no one else."
"Very well, Francois," answered the boy.
"Tell my wife I may be late, but I will surely come."
The boy went away, and Francois went up to Ben's room.
"Monsieur, I have something to say to you," he commenced.
"What is it, Francois?"
"You said you would give a hundred francs to any one who would
get you out of this?"
"Yes, Francois," answered Ben, quickly.
"Have you so much money with you, then?" asked Francois,
doubtfully.
"See here!" and Ben took out five napoleons, which he displayed in
his open palm.
The attendant's eyes sparkled.
"And you will give them to me, if perchance I set you free?"
"Yes."
"Listen, then. I would not do it, but my little Marie is very sick, and
my wife wants me to come home. Perhaps she may die;" and the
poor fellow suppressed a sob. "But M. Bordon—that is the doctor—
he says I shall not go. He said 'Plague take your child!'" continued
Francois, wrathfully.
"Poor Francois," said Ben compassionately.
"Ah! you feel for me, little monsieur," said Francois, gratefully. "The
doctor has a heart like a stone. He says if I go I shall not come
back; but I do not care, I cannot stay away. I will go, and you shall
go with me. Can you walk five miles?"
"I can walk ten—fifteen, if necessary," said Ben, promptly.
"Then be ready at midnight. We will go together. It will not do to go
earlier. Then the doctor will be asleep. Every one else will be asleep,
and we can go away unobserved. M. Bourdon will be sorry that he
did not let me go. I promised to come back." And Francois's eyes
sparkled with honest indignation.
Ben's heart beat high with hope.
"You will come to my room at midnight?" he said.
"Yes, monsieur."
"I will be ready."
"One thing, monsieur. Do not have your shoes on. You can carry
them in your hand. We must not make any noise when we are going
down stairs, or we may be caught."
"That is well thought of, Francois. Depend upon me. I will be ready."
It will easily be supposed that Ben did not go to bed. He sat waiting
patiently hour after hour till, as midnight struck, his door was softly
opened, and Francois appeared.
"Now," said the attendant, "follow me, and make no noise."
Ben, in his stocking feet, followed the attendant down stairs.
Producing a large key, Francois opened the outside door, then closed
it softly, and they stood outside under a star-lit sky.
CHAPTER XXVIII.
Ben's Flight.
As good luck would have it, Ben and Francois departed without
being observed. On emerging from the asylum they at first ran, after
putting on their shoes, but when a quarter of a mile had been
traversed they dropped into a walk.
"Well, we got away safely," said Ben.
"Yes; the doctor was asleep. We shall not be missed till morning."
"And then it shall be my fault if I am caught. Where is your home,
Francois?"
"Five miles away."
"Yes, but is it on my way?"
"Where would monsieur go?"
"To Paris."
"To Paris!" ejaculated Francois, with wonderment. "That is a great
way off, is it not?"
"Yes, I think it must be a thousand miles away."
"But monsieur is a boy; he cannot walk so far."
"No," answered Ben, laughing. "I don't propose to. Is there any
railroad station near your house?"
"Yes, monsieur; only five minutes off."
"That will do very well."
"And has monsieur money enough?"
"Not to go all the way to Paris, but half-way there, perhaps."
"And is not monsieur afraid he will starve—without money?"
"I think I can get along," said Ben, slowly, for it dawned upon him
that it would not be a very pleasant thing to be penniless in a
foreign country.
"I will give back half the money monsieur has given me," said
Francois, in a friendly tone.
"No, Francois; you will need it all. I am not afraid."
After a walk of an hour and a half the two pedestrians reached a
small village set among the hills. Francois began to walk faster, and
to look more eager.
"Does monsieur see that cottage?" he said.
Ben's eyes rested on an humble cottage just out of the village.
"Yes."
"It is mine. Will monsieur come with me?"
"Yes, I will go to see if your little girl is alive."
Soon they were at the door. There was a light burning in the main
room. A plain, neat woman opened the door.
"Thank Heaven!" she exclaimed, "it is Francois."
"Is—is Marie alive?"
"Yes, my husband. She has had a change for the better."
"Heaven be praised!"
"And who is this young gentleman?"
"A friend," answered Francois, after some hesitation.
"Then I'm glad to see him. Welcome, monsieur."
"Come in, monsieur," said Francois.
"I think I had better go to the station."
"The cars will not start till seven o'clock. Monsieur will need repose."
"But I don't wish to incommode you."
"My wife will give you a blanket, and you can lie here."
Ben accepted the invitation, and stretched himself out on a settee.
"I will wake you in time," said Francois. "Be tranquil."
CHAPTER XXIX.
Ben Is Missed.
Meanwhile M. Bourdon slept the sleep of the just—or the unjust—not
dreaming of the loss his establishment had sustained. He did not
open his eyes till five o'clock.
Usually at that hour Francois was stirring, as he had morning duties
to perform. But M. Bourdon did not hear him bustling around as
usual. At first this did not strike him, but after awhile he began to
wonder why.
"The lazy dog!" he said to himself. "He is indulging himself this
morning, and his work will suffer."
He went to the door of his chamber and called "Francois!"
Francois slept in an upper room, but still the asylum was not a lofty
building, and he should have heard.
"He must be fast asleep, as usual," grumbled M. Bourdon. "I must
go up and rouse him. It would be well if I had a horsewhip."
Slipping on a part of his clothing, the doctor crept up stairs.
He knocked at the door of his dilatory servant.
"Francois! Francois, I say. Are you dead?"
There was no answer.
"I suppose he has locked his door," muttered the doctor, as he tried
the latch.
But no! the door opened, and, to his dismay, the room was empty.
The bed had not been disturbed.
The doctor's face was dark with anger.
"The ingrate has left me, after all. He has gone to his child, who is
not sick at all, I dare say. Well, he will repent it. I will not take him
back."
Here the doctor paused. It would be exceedingly inconvenient to
lose Francois, who, besides being a capable man, accepted very
small pay.
"At any rate I will lower his wages!" he said. "He shall regret the way
he has served me."
It was a temporary inconvenience. Still there was an outside man
whom he could impress into the service as a substitute, and in a day
or two Francois would be glad to return. It was not, perhaps, so
serious a matter, after all.
But M. Bourdon changed his mind when he found the front door
unlocked.
"Who had escaped, if any?"
This was the question he asked himself. In great haste he went from
one room to another, but all seemed to be occupied. It was only
when he opened Ben's room that he ascertained that the one whom
he would most regret to lose had decamped. Ben's bed, too, was but
little disturbed. He had slept on the outside, if he had slept at all,
but not within the bed, as was but too evident.
"Has any one seen the boy?" demanded M. Bourdon of an outdoor
servant who slept outside, but was already on duty.
"Not I, Monsieur le Docteur."
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like