0% found this document useful (0 votes)
10 views63 pages

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane pdf download

The document is a comprehensive guide titled 'A Web-Based Introduction to Programming' by Mike O'Kane, focusing on essential algorithms, syntax, and control structures using PHP, HTML, and MariaDB/MySQL. It covers various programming concepts, client/server applications, program design, and database connectivity, along with practical exercises and review questions. The book is intended for instructional purposes and includes bibliographical references and an index.

Uploaded by

sndpmqhy5896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views63 pages

A Web Based Introduction to Programming Essential Algorithms Syntax and Control Structures Using Php Html and Mariadb MySQL Mike O’Kane pdf download

The document is a comprehensive guide titled 'A Web-Based Introduction to Programming' by Mike O'Kane, focusing on essential algorithms, syntax, and control structures using PHP, HTML, and MariaDB/MySQL. It covers various programming concepts, client/server applications, program design, and database connectivity, along with practical exercises and review questions. The book is intended for instructional purposes and includes bibliographical references and an index.

Uploaded by

sndpmqhy5896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

A Web Based Introduction to Programming

Essential Algorithms Syntax and Control


Structures Using Php Html and Mariadb MySQL Mike
O’Kane download
https://textbookfull.com/product/a-web-based-introduction-to-
programming-essential-algorithms-syntax-and-control-structures-
using-php-html-and-mariadb-mysql-mike-okane/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

PHP and MySQL for Dynamic Web Sites Fifth Edition


Ullman

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

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/

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/

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/
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/

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/

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/

Learning PHP, MySQL & JavaScript, 6th Edition Robin


Nixon

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

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/
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
advantage of the wind, the desert banditti are able to advance to the attack,
just as the devil-fish do on the sea-bottom, under cover of sand-clouds of
their own stirring up; and the first intimation which the traveller has of the
character of those who are coming towards him, is the sudden flash of
swords and glitter of spearheads that light up the edges of the advancing
sand, just as lightning flits along the ragged skirts of a moving thunder-
cloud.

But here there are no Murri or Bhoogti horsemen astir, and the Indians,
Piutes or Navajos, have not acquired Beluchi tactics. These moving clouds
here are raised by loitering sheep, formidable only to Don Quixote and the
low-nesting ground-larks. They are close feeders, though, these sheep, and
it is poor gleaning after them, so it is a rule throughout the Territory that on
the hills where sheep graze, game need not be looked for.

An occasional ranch comes in sight, and along the old county road a
waggon or two goes crawling by, and then we reach Mona, a pretty little
rustic spot, but the civilizing radiance of corn-fields gradually dies away,
and the relentless sage-brush supervenes, with here and there a lucid
interval of ploughed ground in the midst of the demented desert. With water
the whole valley would be superbly fertile, as we soon see, for there
suddenly breaks in upon the monotony of the weed-growths a splendid
succession of fields, long expanses of meadowland, large groves of
orchards, and the thriving settlement of Nephi.

Like all other prosperous places in Utah, it is almost entirely Mormon.


There is one saloon, run by a Mormon, but patronized chiefly by the
"outsiders"—for such is the name usually given to the "Gentiles" in the
settlement—and no police. Local mills meet local requirements, and the
"co-op." is the chief trading store of the place. There are no manufactures
for export, but in grain and fruit there is a considerable trade. It is a quaint,
straggling sort of place, and, like all these settlements, curiously primitive.
The young men use the steps of the co-operative store as a lounge, and their
ponies, burdened with huge Mexican saddles and stirrups that would do for
dog-kennels, stand hitched to the palings all about. The train stops at the
corner of the road to take up any passengers there may be. Deer are
sometimes killed in the streets, and eagles still harry the chickens in the
orchards. Wild-bird life is strangely abundant, and a flock of "canaries"—a
very beautiful yellow siskin—had taken possession of my host's garden.
"We do catch them sometimes," said his wife, "but they always starve
themselves, and pine away till they are thin enough to get through the bars
of the cage, and so we can never keep them." A neighbour who chanced in,
was full of canary-lore, and I remember one incident that struck me as very
pretty. He had caught a canary and caged it, but the bird refused to be
tamed, and dashed itself about the cage in such a frantic way that out of
sheer pity he let the wild thing go. A day or two later it came back, but with
a mate, and when the cage was hung out the two birds went into captivity
together, of their own free-will, and lived as happily as birds could live!

My host was a good illustration of what Mormonism can do for a man. In


Yorkshire he was employed in a slaughtering-yard, and thought himself
lucky if he earned twelve shillings a week. The Mormons found him,
"converted" him, and emigrated him. He landed in Utah without a cent in
his pocket, and in debt to the Church besides. But he found every one ready
to help him, and was ready to help himself, so that to-day he is one of the
most substantial men in Nephi, with a mill that cost him $10,000 to put up,
a shop and a farm, a house and orchard and stock. His family, four
daughters and a son, are all settled round him and thriving, thanks to the aid
he gave them—"but," said he, "if the Mormons had not found me, I should
still have been slaughtering in the old country, and glad, likely, to be still
earning my twelve shillings a week." Another instance from the same
settlement is that of a boy who, five years ago, was brought out here at the
age of sixteen. His emigration was entirely paid for by the Church. Yet last
year he sent home from his own pocket the necessary funds to bring out his
mother and four brothers and sisters! God speed these Mormons, then. They
are doing both "the old country and the new" an immense good in thus
transforming English paupers into American farmers—and thus exchanging
the vices and squalor of English poverty for the temperance, piety, and
comfort of these Utah homesteads. I am not blind to their faults. My
aversion to polygamy is sincere, and I find also that the Mormons must
share with all agricultural communities the blame of not sacrificing more of
their own present prospects for the sake of their children's future, and
neglecting their education, both in school and at home. But when I
remember what classes of people these men and women are chiefly drawn
from, and the utter poverty in which most of them I cannot, in sincerity, do
otherwise than admire and respect the system which has fused such
unpromising material of so many nationalities into one homogeneous
whole.

For myself, I do not think I could live among the Mormons happily, for my
lines have been cast so long in the centres of work and thought, that a
bovine atmosphere of perpetual farms suffocates me. I am afraid I should
take to lowing, and feed on lucerne. But this does not prejudice me against
the men and women who are so unmistakably happy. They are uncultured,
from the highest to the lowest. But the men of thirty and upwards remember
these valleys when they were utter deserts, and the Indian was lord of the
hills! As little children they had to perform all the small duties about the
house, the "chores," as they are called; as lads they had to guard the stock
on the hills; as young men they were the pioneers of Utah. What else then
could they be but ignorant—in the education of schools, I mean? Yet they
are sober in their habits, conversation, and demeanour, frugal, industrious,
hospitable, and God-fearing. As a people, their lives are a pattern to an
immense number of mankind, and every emigrant, therefore, taken up out
of the slums of manufacturing cities in the old countries, or from the
hideous drudgery of European agriculture, and planted in these Utah
valleys, is a benefit conferred by Mormonism upon two continents at once.

To return to Nephi. I went to a "meeting" in the evening, and to describe


one is to describe all. The old men and women sit in front—the women, as a
rule, all together in the body of the room, and the men at the sides. How this
custom originated no one could tell me; but it is probably a survival of habit
from the old days when there was only room enough for the women to be
seated, and the men stood round against the walls, and at the door. As larger
buildings were erected, the women, as of old, took their accustomed seats
together in the centre, and the men filled up the balance of the space. The
oldest being hard of hearing and short of sight, would naturally, in an
unconventional society, collect at the front of the audience. Looking at them
all together, they are found to be exactly what one might expect—a
congregation of hard-featured, bucolic faces, sun-tanned and deep-lined.
Here and there among them is a bright mechanic's face, and here and there
an unexpected refinement of intelligence. But taken in the mass, they are
precisely such a congregation as fills nine-tenths of the rural places of
worship all the world over. Conspicuously absent, however, is the typical
American face, for the fathers and mothers among the Mormons are of
every nationality, and the sons and daughters are a mixture of all. In the
future this race should be a very fine one, for it is chiefly recruited from the
hardier stocks, the English, Scotch, and Scandinavian, while their manner
of life is pre-eminently fitted for making them stalwart in figure, and sound
in constitution.

The meeting opens with prayer, in which the Almighty is asked for
blessings upon the whole people, upon each class of it, upon their own
place in particular, upon all the Church authorities, and upon all friends of
the Mormons. But never, so far as I have heard, are intercessions made, in
the spirit of New Testament teaching, for the enemies of the Church.
References to the author of the Edmunds Bill are often very pointed and
vigorous. After the prayer comes a hymn, sung often to a lively tune, and
accompanied by such instrumental music as the settlement can rely upon,
after which the elders address the people in succession. These addresses are
curiously practical. They are temporal rather than spiritual, and concern
themselves with history, official acts, personal reminiscences, and
agricultural matter rather than points of mere doctrine. But as a fact,
temporal and spiritual considerations are too closely blended in Mormonism
to be disassociated. Thus references to the Edmunds Bill take their place
naturally among exhortations to "live their religion", and to "build up the
kingdom" in spite of "persecution." Boycotting Gentile tradesmen is
similarly inculcated as showing a pious fidelity to the interests of the
Church. These are the two chief topics of all addresses, but a passing
reference to a superior class of waggon, or a hope that every one will make
a point of voting in some coming election, is not considered out of place,
while personal matters, the health of the speaker or his experiences in
travel, are often thus publicly commented upon. The result is, that the
people go away with some tangible facts in their heads, and subjects for
ordinary conversation on their tongues, and not, as from other kinds of
religious meetings, with only generalities about their souls and the Ten
Commandments. In other countries the gabble of small-talk that
immediately overtakes a congregation let out of church sounds very
incongruous with the last notes of the organ voluntary that play them out of
the House of God. But here the people walking homeward are able to
continue the conversation on exactly the same lines as the addresses they
have just heard, to renew it the next day, to carry it about with them as
conversation from place to place, and thus eventually to spread the
"doctrine" of the elders over the whole district. A fact about waggon-buying
sticks where whole sermons about salvation by faith would not.
CHAPTER XII.
FROM NEPHI TO MANTI.

English companies and their failures—A


deplorable neglect of claret cup—Into the
San Pete Valley—Reminiscences of the
Indians—The forbearance of the red man—
The great temple at Manti—Masonry and
Mormon mysteries—In a tithing-house.

FROM Nephi, a narrow-guage line runs up the Salt Creek canyon, and
away across a wilderness to a little mining settlement called Wales,
inhabited by Welsh Mormons who work at the adjacent coal-mines. The
affair belongs to an English company, and it is worth noting that "English
companies" are considered here to be very proper subjects for jest. When
nobody else in the world will undertake a hopeless enterprise, an English
company appears to be always on hand to embark in it, and this fact
displays a confidence on the part of Americans in British credulity, and a
confidence on the part of the Britishers in American honesty, which ought
to be mutually instructive. Meanwhile this has nothing to do with these
coal-mines in the San Pete Valley, which, for all I know, may be very sound
concerns, and very profitable to the "English company" in question. I hope
it is. The train was rather a curious one, though, for it stopped for
passengers at the corner of the street, and when we got "aboard," we found
a baggage car the only vehicle provided for us. A number of apostles and
elders were on Conference tour, and the party, therefore, was a large one; so
that, if the driver had been an enthusiastic anti-Mormon, he might have
struck a severe blow at the Church by tilting us off the rails. The Salt Creek
canyon is not a prepossessing one, but there grew in it an abundance of
borage, the handsome blue heads of flowers showing from among the
undergrowth in large patches.
What a waste of borage! Often have I deplored over my claret in India the
absence of this estimable vegetable, and here in Utah with a perfect jungle
of borage all about me, I had no claret! I pointed out to the apostles with us
that temperance in such a spot was flying in the face of providence, and
urged them to plant vineyards in the neighbourhood. But they were not
enthusiastic, and I relapsed into silent contemplation over the incredible
ways of nature, that she should thus cast her pearls of borage before a
community of teetotallers.

Traversing the canyon, we enter San Pete Valley, memorable for the Indian
War of 1865-67, but in itself as desolate and uninteresting a tract of country
as anything I have ever seen. Ugly bald hills and leprous sand-patches in
the midst of sage-brush, combined to form a landscape of utter dreariness;
and the little settlements lying away under the hills on the far eastern edge
of the valley—Fountain Green, Maroni, and Springtown—seemed to me
more like penal settlements than voluntary locations. Yet I am told they are
pretty enough, and certainly Mount Pleasant, the largest settlement in the
San Pete country, looked as if it deserved its name. But it stands back well
out of the desperate levels of the valley, and its abundant foliage tells of
abundant water. A pair of eagles circled high up in the sky above us as we
rattled along, expecting us apparently to die by the way, and hoping to be
our undertakers. A solitary coyote was pointed out to me, a lean and
uncared-for person, that kept looking back over its shoulder as it trotted
away, as if it had a lingering sort of notion that a defunct apostle might by
chance be thrown overboard. It was a hungry and a thirsty looking country,
and Wales, where we left our train, was a dismal spot. Here we found
waggons waiting for us, and were soon on our way across the desert,
passing a settlement-oasis now and again, and crossing the San Pete "river,"
which here sneaks along, a muddy, shallow stream, at the bottom of high,
willow-fringed banks. And so to Fort Ephraim, a quaint little one-street sort
of place that looks up to Manti, a few miles off, as a little boy looks up to
his biggest brother, and to Salt Lake City as a cat might look up to a king.

In 1865-67, however, it was an important point. Several companies of the


Mormon militia were mustered here, and held the mountains and passes on
the east against the Indians, guarded the stock gathered here from the other
small settlements that had been abandoned, and took part in the fights at
Thistle Creek, Springtown, Fish Lake, Twelve Mile Creek Gravelly Ford,
and the rest, where Black Hawk and his flying squadron of Navajos and
Piutes showed themselves such plucky men. It is a pity, I think, that the
history of that three years' campaign has never been sketched, for, as men
talk of it, it must have abounded with stirring incident and romance.
Besides, a well-written history of such a campaign, with the lessons it
teaches, might be useful some day—for the fighting spirit of the Indians is
not broken, and when another Black Hawk appears upon the scene, 1865
might easily be re-enacted, and Fort Ephraim once more be transformed
from a farming hamlet to a military camp.

Yet I have often wondered at the apathy or the friendship of the Indians.
Herds of cattle and horses and sheep wander about among the mountains
virtually unguarded. Little villages full of grain, and each with its store well
stocked with sugar, and tobacco, and cloths, and knives, and other things
that the Indians prize, lie almost defenceless at the mouths of canyons. Yet
they have not been molested for the last fifteen years. I confess that if I
were an Indian chief, I should not be able to resist the temptation of helping
my tribe to an occasional surfeit of beef, with the amusement thrown in of
plundering a co-operative store. But the Mormons say that the Indian is
more honest than a white man and, in illustration of this, are ready to give
innumerable instances of an otherwise inexplicable chivalry. For one thing,
though, the Mormons are looked upon by the Indians in quite a different
light to other Americans, for they consider them to be victims, like
themselves, of Federal dislike, while both as individuals and a class they
hold them in consideration as being superior to Agents in fidelity to
engagements. So that the compliment of honesty is mutually reciprocated.
To illustrate this aspect of the Mormon-Indian relations, some Indians came
the other day into a settlement and engaged in a very protracted pow-wow,
the upshot of all their roundabout palaver being this, that inasmuch as they,
the Indians, had given Utah to the Mormons, it was preposterous for the
Mormons to pay the Government for the land they took up!

From Fort Ephraim to Manti the road lies chiefly through unreclaimed land,
but within a mile or two of the town the irrigated suburbs of Manti break in
upon the sage-brush, and the Temple, which has been visible in the distance
half the day, grows out from the hills into definite details. The site of this
imposing structure certainly surprised me both for the fine originality of its
conception, and the artistic sympathy with the surrounding scenery, which
has directed its erection. The site originally was a rugged hill slope, but this
has been cut out into three vast semicircular terraces, each of which is faced
with a wall of rough hewn stone, seventeen feet in height. Ascending these
by wide flights of steps, you find yourself on a fourth level, the hill top,
which has been levelled into a spacious plateau, and on this, with its back
set against the hill, stands the temple. The style of Mormon architecture,
unfortunately, is heavy and unadorned, and in itself, therefore, this massive
pile, 160 feet in length by 90 wide, and about 100 high, is not
prepossessing, But when it is finished, and the terrace slopes are turfed, and
the spaces planted out with trees, the view will undoubtedly be very fine,
and the temple be a building that the Mormons may well be proud of.
Looked at from the plain, with the stern hills behind it, the edifice is seen to
be in thoroughly artistic harmony with the scene, while the enormous
expenditure of labour upon its erection is a matter for astonishment. The
plan of the building inside differs from those of the temples at Logan, St.
George, and Salt Lake City, which again differ from each other, for it is a
curious fact that the ritual of the secret ceremonies to which these buildings
are chiefly devoted, is still under elaboration and imperfect, so that each
temple in turn partially varies from its predecessor, to suit the latest
alterations made in the Endowments and other rites celebrated within its
walls. In my description of the Logan Temple, I gave a sketch of the
purposes for which the various parts of the building were intended. That
sketch, of course, cannot pretend to be exact, for only those Mormons who
have "worked" through the degrees can tell the whole truth; and as yet no
one has divulged it. But with a general knowledge of the rites, and an
intimate acquaintance with freemasonry, I have, I believe, put together the
only reliable outline that has ever been published. The Manti temple will
have the same arrangements of baptismal font and dressing-rooms on the
ground floor, but as well as I could judge from the unfinished state of the
building, the "endowments," in the course of which are symbolical
representations of the Creation, Temptation and Fall, will be spread over
two floors, the apartment for "baptism for the dead" occupying a place on
the lower. The "sealing" is performed on the third. I have an objection to
prying into matters which the Mormons are so earnest in keeping secret, but
as a mason, the connexion between Masonry and Mormonism is too
fascinating a subject for me to resist curiosity altogether.

As a settlement, Manti is pretty, well-ordered and prosperous. The universal


vice of unbridged water-courses disfigures its roads just as it does those of
every other place (Salt Lake City itself not excepted), and the irregularity in
the order of occupation of lots gives it the same scattered appearance that
many other settlements have. But the abundance of trees, the width of the
streets, the perpetual presence of running water, the frequency and size of
the orchards, and the general appearance of simple, rustic, comfort impart
to Manti all the characteristic charm of the Mormon settlements. The
orthodox grist and saw-mills, essential adjuncts of every outlying hamlet,
find their usual place in the local economy; but to me the most interesting
corner was the quaint tithing-house, a Dutch-barn kind of place, still
surrounded by the high stone stockade which was built for the protection of
the settlers during the Indian troubles fifteen years ago. Inside the tithing-
house were two great bins half filled with wheat and oats, and a few
bundles of wool. I had expected to find a miscellaneous confusion of
articles of all kinds, but on inquiry discovered that the popular theory of
Mormon tithing, "a tenth of everything,"—"even to the tenth of every egg
that is laid," as a Gentile lady plaintively assured me, is not carried out in
practice, the majority of Mormons allowing their tithings to run into arrears,
and then paying them up in a lump in some one staple article, vegetable or
animal, that happens to be easiest for them. The tenth of their eggs or their
currant jam does not, therefore, as supposed, form part of the rigid annual
tribute of these degraded serfs to their grasping masters. As a matter of fact,
indeed, the payment of tithings is as nearly voluntary as the collection of a
revenue necessary for carrying on a government can possibly be allowed to
be. What it may have been once, is of no importance now. But to-day, so far
from there being any undue coercion, I have amply assured myself that
there is extreme consideration and indulgence, while the general prosperity
of the territory justifies the leniency that prevails.
CHAPTER XIII.
FROM MANTI TO GLENWOOD.

Scandinavian Mormons—Danish ol—


Among the Orchards at Manti—On the way
to Conference—Adam and Eve—The
protoplasm of a settlement—Ham and eggs
—At Mayfield—Our teamster's theory of the
ground-hog—On the way to Glenwood—
Volcanic phenomena and lizards—A
suggestion for improving upon Nature—
Primitive Art

"MY hosts at Manti were Danes, and the wife brewed Danish ol." Such is
the entry in my note-book, made, I remember, to remind me to say that the
San Pete settlements are composed in great proportion of Danes and
Scandinavians. These nationalities contribute more largely than any other—
unless Great-Britishers are all called one nation—to the recruiting of
Mormonism, and when they reach Utah maintain their individuality more
conspicuously than any others. The Americans, Welsh, Scotch, English,
Germans, and Swiss, merge very rapidly into one blend, but the
Scandinavian type—and a very fine peasant type it is—is clearly marked in
the settlements where the Hansens and the Jansens, Petersens,
Christiansens, Nielsens, and Sorensens, most do congregate. By the way,
some of these Norse names sound very curiously to the ear. "Ole Hagg"
might be thought to be a nickname rather than anything else, and Lars
Nasquist Brihl at best a joke. Their children are remarkably pretty, and the
women models of thriftiness.

My hostess at Manti was a pattern. She made pies under an inspiration, and
her chicken-pie was a distinct revelation. Her "beer" was certainly a
beverage that a man might deny himself quite cheerfully, but to eat her
preserves was like listening to beautiful parables, and her cream cheese
gave the same gentle pleasure as the singing of thankful canticles.

In the garden was an arbour overrun with a wild grapevine, and I took my
pen and ink in there to write. All went well for a while. An amiable cat
came and joined me, sitting in a comfortable cushion-sort of fashion on the
corner of my blotting-pad. But while we sat there writing, the cat and I,
there came a humming-bird into the arbour—a little miracle in feathers,
with wings all emeralds and a throat of ruby. And it sat in the sunlight on a
vine-twig that straggled out across the door, and began to preen its tiny
feathers. I stopped writing to watch the beautiful thing. And so did the cat.
For happening to look down at the table I saw the cat, with a fiendish
expression of face and her eyes intent on the bird, gathering her hind legs
together for a spring. To give the cat a smack on the head, and for the cat to
vanish with an explosion of ill-temper, "was the work of an instant." The
humming-bird flashed out into the garden, and I was left alone to mop up
the ink which the startled cat had spilt. Then I went out and wandered
across the garden, where English flowers, the sweet-william and columbine,
pinks and wallflowers, pansies and iris, were growing, under the fruit-trees
still bunched with blossoms, and out into the street. Friends asked me if I
wasn't going to "the conference," but I had not the heart to go inside when
the world out of doors was so inviting. There was a cool, green tint in the
shade of the orchards, pleasant with the voices of birds and dreamy with the
humming of bees. There was nobody else about, only children making
posies of apple-blossoms and launching blue boats of iris-petals on the little
roadside streams. Everybody was "at conference," and those that could not
get into the building were grouped outside among the waggons of the
country folk who had come from a distance. These conferences are held
quarterly (so that the lives of the Apostles who preside at them are virtually
spent in travelling) and at them everything is discussed, whether of spiritual
or temporal interest and a general balance struck, financially and
religiously. In character they resemble the ordinary meetings of the
Mormons, being of exactly the same curious admixture of present farming
and future salvation, business advice and pious exhortation.

Everybody who can do so, attends these meetings; and they fulfil, therefore,
all the purposes of the Oriental mela. Farmers, stock-raisers, and dealers
generally, meet from a distance and talk over business matters, open
negotiations and settle bargains, exchange opinions and discuss prospects.
Their wives and families, such of them as can get away from their homes,
foregather and exchange their domestic news, while everybody lays in a
fresh supply of spiritual refreshment for the coming three months, and hears
the latest word of the Church as to the Edmunds Bill and Gentile tradesmen.
The scene is as primitive and quaint as can be imagined, for in rural Utah
life is still rough and hearty and simple. To the stranger, the greetings of
family groups, with the strange flavour of the Commonwealth days, the
wonderful Scriptural or apocryphal names, and the old-fashioned salutation,
are full of picturesque interest, while the meetings of waggons filled with
acquaintances from remote corners of the country, the confusion of
European dialects—imagine hearing pure Welsh among the San Pete
sagebrush!—the unconventional cordiality of greeting, are delightful both
in an intellectual and artistic sense.

I have travelled much, and these social touches have always had a charm
for me, let them be the demure reunions of Creoles sous les filaos in
Mauritius; or the French negroes chattering as they go to the baths in
Bourbon; the deep-drinking convivialities of the Planters' Club in Ceylon;
the grinning, prancing, rencontres of Kaffir and Kaffir, or the stolid
collision of Boer waggons on the African veldt; the stately meeting of
camel-riding Beluchis on the sandy put of Khelat; the jingling ox-drawn
ekkas foregathered to "bukh" under the tamarind-trees of Bengal; the
reserved salutations of Hindoos as they squat by the roadside to discuss the
invariable lawsuit and smoke the inevitable hubble-bubble; the noisy
congregation of Somali boatmen before their huts on the sun-smitten shores
of Aden;—what a number of reminiscences I could string together of social
traits in various parts of the world! And these Mormon peasants, pioneers of
the West, these hardy sons of hardy sires, will be as interesting to me in the
future as any others, and my remembrance of them will be one of
admiration for their unfashionable virtues of industry and temperance, and
of gratitude for their simple courtesy and their cordial hospitality.

As we left Manti behind us, the waggons "coming into conference" got
fewer and fewer, and soon we found ourselves out alone upon the broad
levels of the valley, with nothing to keep us company but a low range of
barren hills that did their best to break the monotony of the landscape. In
places, the ground was white with desperate patches of "saleratus," the
saline efflorescence with which agriculture in this Territory is for ever at
war, and resembling in appearance, taste, and effects the "reh" of the
Gangetic plains. Here, as in India, irrigation is the only known antidote, and
once wash it out of the soil and get crops growing and the enemy retires.
But as soon as cultivation ceases or irrigation slackens, the white infection
creeps over the ground again, and if undisturbed for a year resumes
possession. How unrelenting Nature is in her conflict with man!

We passed some warm springs a few miles from Manti, but the water
though slightly saline is inodorous, and on the patches which they water I
saw the wild flax growing as if it enjoyed the temperature and the soil. Then
Six-Mile Creek, a pleasant little ravine, crossed by a rustic bridge, which
gives water for a large tract Of land, and so to Sterling, a settlement as yet
in its cradle, and curiously illustrative of "the beginning of things" in rural
Utah. One man and his one wife up on the hillside doing something to the
water, one cock and one hen pecking together in monogamous sympathy,
one dog sitting at the door of a one-roomed log-hut. Everything was in the
Adam and Eve stage of society, and primeval. So Deucalion and Pyrrha had
the earth to themselves, and the "rooster" stalked before his mate as if he
was the first inventor of posterity. But much of this country is going to
come under the plough in time, for there is water, and in the meantime, as
giving promise of a future with some children in it, there is a school-house
—an instance of forethought which gratified me.

The country now becomes undulating, remaining for the most part a sterile-
looking waste of grease-wood, but having an almost continuous thread of
cultivation running along the centre of the valley which, a few miles further
on, suddenly widens into a great field of several thousand acres. On the
other side of it we found Mayfield.

In Mayfield every one was gone to the Conference except a pretty girl, left
to look after all the children of the village, and who resisted our entreaties
for hospitality with a determination that would have been more becoming in
an uglier person—and an old lady, left under the protection of a big blind
dog and a little bobtailed calf. She received us with the honest courtesy
universal in the Territory, showed us where to put our horses and where the
lucerne was stacked, and apologized to us for having nothing better than
eggs and ham to offer!

Fancy nothing better than eggs and ham! To my mind there is nothing in all
travelling so delightful as these eggs-and-ham interruptions that do duty for
meals. Not only is the viand itself so agreeable, but its odour when cooking
creates an appetite.

What a moral there is here! We have all heard of the beauty of the lesson
that those flowers teach us which give forth their sweetest fragrance when
crushed. But I think the conduct of eggs and ham, that thus create an
appetite in order to increase man's pleasure in their own consumption, is
attended with circumstances of good taste that are unusually pleasing.

In our hostess's house at Mayfield I saw for the first time the ordinary floor-
covering of the country through which we subsequently travelled—a "rag-
carpet." It is probably common all over the world, but it was quite new to
me. I discussed its composition one day with a mother and her daughter.

"This streak here is Jimmy's old pants, and that darker one is a military
overcoat. This is daddy's plush vest. This bit of the pattern is—"

"No, mother, that's your old jacket-back; don't you remember?"—and so on


all through the carpet.

Every stripe in it had an association, and the story of the whole was pretty
nearly the story of their entire lives in the country.

"For it took us seven years to get together just this one strip of carpet. We
folks haven't much, you see, that's fit to tear up."

I like the phrase "fit to tear up," and wonder when, in the opinion of this
frugal people, anything does become suitable for destruction. But it is
hardly destruction after all to turn old clothes into carpets, and the process
is as simple as, in fact is identical with, ordinary hand-weaving. The cloth is
simply shredded into very narrow strips, and each strip is treated in the
loom just as if it were ordinary yarn, the result being, by a judicious
alternation of tints, a very pleasant-looking and very durable floor-cloth.
Rag-rugs are also made on a foundation of very coarse canvas by drawing
very narrow shreds of rag through the spaces of the canvas, fastening them
on the reverse side, and cutting them off to a uniform "pile" on the upper. In
one cottage at Salina I remember seeing a rug of this kind in which the girl
had drawn her own pattern and worked in the colours with a distinct
appreciation of true artistic effect. An industrial exhibition for such products
would, I have no doubt, bring to light a great many out-of-the-way
handicrafts which these emigrant people have brought with them from the
different parts of Europe, and with which they try to adorn their simple
homes.

Our teamster from Mayfield to Glenwood, the next stage of my southward


journey, was a very cautious person. He would not hurry his horses down
hill—they were "belike" to stumble; and he would not hurry them up hill—
it "fretted" them. On the level intervals he stopped altogether, to "breathe"
them. It transpired eventually that they were plough horses. I suspected it
from the first. And from his driving I suspected that he was the ploughman.
In other respects he was a very desirable teamster.

His remarks about Europe (he had once been to Chicago himself) were very
entertaining, and his theory of "ground hogs" would have delighted Darwin.
As far as I could follow him, all animals were of one species, the
differences as to size and form being chiefly accidents of age or sex. This,
at any rate, was my induction from his description of the "ground hog,"
which he said was a "kind of squirrel—like the prairie dog!" As he said,
there were "quite a few" ground hogs, but they moved too fast among the
brush for me to identify them. As far as I could tell, though, they were of
the marmot kind, about nine inches long, with very short tails and round
small ears. When they were at a safe distance they would stand up at full
length on their hind legs, the colouring underneath being lighter than on the
back. What are they? I have seen none in Utah except on these volcanic
stretches of country between Salina and Monroe.

Much of Utah is volcanic, but here, beyond Salina, huge mounds of scoriae,
looking like heaps of slag from some gigantic furnace, are piled up in the
centre of the level ground, while in other places circular depressions in the
soil—sometimes fifty feet in diameter and lowest in the centre, with deep
fissures defining the circumference—seem to mark the places whence the
scoriae had been drawn, and the earth had sunk in upon the cavities thus
exhausted.

The two sides of the river (the Sevier) were in striking contrast. On this, the
eastern, was desolation and stone heaps and burnt-up spaces with ant-hills
and lizards.

Nothing makes a place look (to me at least) so hot as an abundance of


lizards. They are associated in memory with dead, still heat, "the intolerable
calor of Mambre," the sun-smitten cinder-heap that men call Aden, the
stifling hillsides of Italy where the grapes lie blistering in the autumn sun,
the desperate suburbs of Alexandria—what millions of scorched-looking
lizards, detestable little salamanders, used to bask upon Cleopatra's Needles
when they lay at full length among the sand!—the heat-cracked fields of
India. I know very well that there are lizards and lizards; that they might be
divided—as the Hindoo divides everything, whether victuals or men's
characters, medicines or the fates the gods send him—into "hot" and "cold"
lizards. The salamander itself, according to the ancients, was icy cold. But
this does not matter. All lizards make places look hot.

On the other side of the river, a favourite raiding-ground of "Mr. Indian," as


the settlers pleasantly call him, lies Aurora, a settlement in the centre of a
rich tract of red wheat soil with frequent growths of willow and buffalo-
berry (or bull-berry or red-berry or "kichi-michi") marking the course of the
Sevier.

But our road soon wound down by a "dug way" to the bottom-lands, and we
found ourselves on level meadows clumped with shrubs and patched with
corn-fields, and among scattered knots of grazing cattle and horses.
Overhead circled several pairs of black hawks, a befitting reminder to the
dwellers on these Thessalian fields, these Campanian pastures, that
Scythian Piutes and Navajo Attilas might at any time swoop down upon
them.

But the forbearance of the Indian in the matter of beef and mutton is
inexplicable—and most inexplicable of all in the case of lamb, seeing that
mint grows wild. This is a very pleasing illustration of the happiness of
results when man and nature work cordially together. The lamb gambols
about among beds of mint! What a becoming sense of the fitness of things
that would be that should surprise the innocent thing in its fragrant pasture
and serve up the two together! "They were pleasant in their lives, and in
death they were not divided." And what a delightful field for similar efforts
such a spectacle opens up to the philosophic mind! Here, beyond Aurora, as
we wind in and out among the brakes of willow and rose-bush, we catch
glimpses of the river, with ducks riding placidly at anchor in the shadows of
the foliage. And not a pea in the neighbourhood! Now, why not sow green
peas along the banks of the American rivers and lakes? How soothing to the
weary traveller would be this occasional relief of canard aux petits pois!

After an interval of pretty river scenery we found ourselves once more in a


dismal, volcanic country with bald hills and leprous sand-patches the only
features of the landscape, with lizards for flowers and an exasperating heat-
drizzle blurring the outlines of everything with its quivering refraction. And
then, after a few miles of this, we are suddenly in the company of really
majestic mountains, some of them cedared to the peaks, others broken up
into splendid architectural designs of almost inconceivable variety, richly
tinted and fantastically grouped. How wealthy this range must be in
mineral! In front of us, above all the intervening hills, loomed out a monster
mountain, and turning one of its spurs we break all at once upon the village
of Glenwood—a beautiful cluster of foliage with skirts of meadow-land
spread out all about it—lying at the foot of the huge slope.

Near Glenwood is an interesting little lake that I visited. Its water is


exquisitely clear and very slightly warm. Though less than a foot deep in
most places (it has one pool twelve feet in depth), it never freezes, in spite
of the intense cold at this altitude. It is stocked with trout that do not grow
to any size, but which do not on the other hand seem to diminish in
numbers, although the consumption is considerable. The botany in the
neighbourhood of the lake is very interesting, the larkspur, lupin, mimulus,
violet, heart's-ease, ox-eye, and several other familiar plants of English
gardens, growing wild, while a strongly tropical flavour is given to the
vegetation by the superb footstools of cactus—imagine sixty-one brilliant
scarlet blossoms on a cushion only fifteen inches across!—by the presence
of a gorgeous oriole (the body a pure yellow freaked with black on the
wings, and the head and neck a rich orange), and by a large butterfly of a
clear flame-colour with the upper wings sharply hooked at the tips. Flower,
bird, and insect were all in keeping with the Brazils or the Malayan
Archipelago.

On a rock, close by the grist-mill, is the only specimen of the much-talked-


of Indian "hieroglyphics" that I have seen. They may of course be
hieroglyphics, but to me they look like the first attempts of some untutored
savage youth to delineate in straight lines the human form divine. Or they
may be only his attempts to delineate a cockroach.
CHAPTER XIV.
FROM GLENWOOD TO MONROE.

From Glenwood to Salina—Deceptiveness of


appearances—An apostate Mormon's
friendly testimony—-Reminiscences of the
Prophet Joseph Smith—Rabbit-hunting in a
waggon—Lost in the sagebrush—A day at
Monroe—Girls riding pillion—The Sunday
drum—Waiting for the right man: "And what
if he is married?"—The truth about apostasy:
not always voluntary.

SOON after leaving Glenwood, cultivation dies out, and for twelve miles or
so the rabbit-brush and grease-wood—the "atriplex" of disagreeably
scientific travellers, who always speak of sage-brush as "artemisia," and
disguise the gentle chipmunk as "spermophilus"—divide the land between
them. The few flowers, and these all dwarfed varieties, attest the poverty of
the soil. The mountains, however, do their best to redeem the landscape,
and the scenery, as desolate scenery, is very fine. The ranges that have on
either hand rolled along an unbroken series of monotonous contour, now
break up into every conceivable variety of form, mimicking architecture or
rather multiplying its types, and piling bluffs, pierced with caves, upon
terraces, and pinnacles upon battlements. Causeways, like that in Echo
Canyon, slant down their slopes, and other vestiges of a terrific aqueous
action abound. Next to this riot of rock comes a long series of low hills,
grey, red, and yellow, utterly destitute of vegetation, and so smooth that it
looks as if the place were a mountain-yard, where Nature made her
mountains, and had collected all her materials about her in separate
convenient mounds before beginning to mix up and fuse. In places they
were richly spangled with mica, giving an appearance of sparkling, trickling
water to the barren slopes.
On the other side of the valley, the mountains, discountenancing such
frivolities, had settled down into solid-bottomed masses of immense bulk,
the largest mountains, in superficial acreage, I had seen all the journey, and
densely cedared.

With Gunnison in sight across the valley, we reached Willow Creek, a


pleasant diversion of water and foliage in the dreary landscape, and an
eventful spot in the last Indian war, for among these willows here Black
Hawk made a stand to dispute the Mormons' pursuit of their plundered
stock, and held the creek, too, all the day. And so out on to the monotonous
grease-wood levels again—an Indians' camp fire among the cedars, the only
sign of a living thing—and over another "divide," and so into the Sevier
Valley. The river is seen flowing along the central depression, with the Red-
Mound settlement on the other side of the stream, and Salina on this side of
it, lying on ahead.

Salina is one of those places it is very hard to catch. You see it first "about
seven" miles off, and after travelling towards it for an hour and a half, find
you have still "eight miles or so" to go. "Appearances are very deceptive in
this country," as these people delight in saying to new-comers, and the
following story is punctually told, at every opportunity, to illustrate it.

A couple of Britishers (of course "Britishers") started off from their hotel
"to walk over to that mountain there," just to get an appetite for breakfast.
About dinner-time one of them gave up and came back, leaving his
obstinate friend to hunt the mountain by himself. After dining, however, he
took a couple of horses and rode out after his friend, and towards evening
came up with him just as he was taking off his shoes and stockings by the
side of a two-foot ditch.

"Hallo!" said the horseman, "what on earth are you doing, Jack?"

"Doing!" replied the other sulkily. "Can't you see? I am taking off my boots
to wade this infernal river."

"River!" exclaimed his friend; "what river? That thing's only a two-foot
ditch!"
"Daresay," was the dogged response. "It looks only a two-foot ditch. But
you can't trust anything in this beastly country. Appearances are so
deceptive."

But we caught Salina at last, for we managed to head it up into a cul-de-sac


of the mountains, and overtook it about sundown. A few years ago the
settlement was depopulated; for Black Hawk made a swoop at it from his
eyrie among the cedars on the overlooking hill, and after killing a few of the
people, compelled the survivors to fly northward, where the militia was
mustering for the defence of the valley. It was in this war that the Federal
officer commanding the post at Salt Lake City, acting under the orders of
General Sherman, refused to help the settlers, telling them in a telegram of
twenty words to help themselves. The country, therefore, remembers with
considerable bitterness that three years' campaign against a most formidable
combination of Indians; when they lost so many lives, when two counties
had to be entirely abandoned, many scattered settlements broken up, and an
immense loss in property and stock suffered.

At Salina I met an apostate Mormon who had deserted the religion because
he had grown to disbelieve in it, but who had retained, nevertheless, all his
respect for the leaders of the Church and the general body of Mormons. He
is still a polygamist; that is to say, having married two wives, he has
continued to treat them honourably as wives. With me was an apostle, one
of the most deservedly popular elders of the Church, and it was capital
entertainment to hear the apostate and the apostle exchanging their jokes at
each other's expense. I was shown at this house, by the way, an emigration
loan receipt. The emigrant, his wife, and three children, had been brought
out in the old waggon days at $50 a head. Some fifteen years later, when the
man had become well-to-do and after he had apostatized, he repaid the
$250, and some $50 extra as "interest." The loan ticket stipulated for "ten
per cent per annum," but as he said, it was "only Mormons who would have
let him run on so long, and then have let him off so much of the interest."

My host was himself an interesting man, for he had been with the Saints
ever since the stormy days of Kirtland, and had known Joseph Smith
personally. "Ah, sir, he was a noble man!" said the old fellow. Among other
out-of-the-way items which he told me about the founder of the faith, was
his predilection for athletic exercises and games of all kinds; how he used to
challenge strangers to wrestle, and be very wroth when, as happened once,
the stranger threw him over the counter of a shop; and how he used to play
baseball with the boys in the streets of Nauvoo. This trait of Joseph Smith's
character I have never seen noticed by his biographers, but it is quite
noteworthy, as also, I think, is the extraordinary fascination which his
personal appearance—for he was a very handsome man of the Sir Robert
Peel type—seems to have exercised over his contemporaries. When
speaking to them, I find that one and all will glance from the other aspects
of his life to this—that he was "a noble man."

Rabbit-hunting across country in a two-horse waggon is not a sport I shall


often indulge in again. The rabbit has things too much its own way. It does
not seem to be a suitable animal for pursuing in a vehicle. It is too evasive.

Indeed, but for an accident, I should probably never have indulged in it at


all. But it happened that on our way from Salina to Monroe we lost our way.
Our teamster, for inscrutable reasons of his own, turned off from the main
road into a bye-track, which proved to have been made by some one
prospecting for clay, and the hole which he had excavated was its terminus.
I tried to think out his reason for choosing this particular road, the least and
most unpromising of the three that offered themselves to him. It was
probably this. Two out of the three roads, being wrong ones, were evils.
One of these was larger than the other, and so of the two evils he chose the
less. Q.E.D.

To get back into the road we struck across the sage-brush, and in so doing
started a jack-rabbit. As it ran in the direction we wanted to go, we naturally
followed it. But the jack-rabbit thought we were in murderous pursuit, and
performed prodigies of agility and strategy in order to escape us. But the
one thing that it ought to have done, got out of our road, it did not do. We
did not gain on the lively animal, I confess, for it was all we could do to
retain our seats, but we gave it enough to prose about all the days of its life.
What stories the younger generation of jack-rabbits will hear of "the old
days" when desperate men used to come out thousands of miles in two-
horse waggons with canvas hoods to try and catch their ancestors! And
what a hero that particular jack-rabbit which we did not hunt will be!
The road southwards leads along hillsides, both up and down, but on the
whole gradually ascending, till the summit of the spur is reached. Here one
of the most enchanting landscapes possible is suddenly found spread out
beneath you. A vast expanse of green meadow-land with pools Of blue
water here and there, herds of horses grazing, flocks of wild fowl in the air,
and on the right the settlement of Richfield among its trees and red-soiled
corn-fields!

Crossing this we found that a spur, running down on it, divides it really into
two, or rather conceals a second plain from sight. But in the second, sage-
brush, "the damnable absinthe," that standard of desolation, waves rampant,
and the telegraph wire that goes straddling across it seems as if it must have
been laid solely for the convenience of larks. Every post has its lark, as
punctually as its insulator, and every lark lets off its three delicious notes of
song as we go by, just as if the birds were sentries passing on a "friend"
from picket to picket. And here it was that we adventured with the jack-
rabbit, much to our own discomfiture. But while we were casting about for
our lost road, we came upon a desolate little building, all alone in the
middle of the waste, which we had supposed to be a deserted ranch-house,
and were surprised to find several waggons standing about. Just as we
reached it, the owners of the waggons came out, and then we discovered
that it was the "meeting-house" for the scattered ranches round, and seeing
the several parties packing themselves into the different waggons
remembered (from a certain Sabbatical smartness of apparel) that it was
Sunday. We were soon on our right road again, and passing the hamlets of
Inverary and Elsinore on the right, came in sight of Monroe, and through a
long prelude of cultivation reached that quaint little village just apparently
at the fashionable hour for girls to go out riding with their beaux.

Couple after couple passed us, the girls riding pillion behind their
sweethearts, and very well contented they all seemed to be, with their arms
round the object of their affections. Except in France once or twice, I do not
recollect ever having seen this picturesque old custom in practice; but
judging from the superior placidity of his countenance and the merriment
on hers, I should say it was an enjoyable one, and perhaps worth reviving.
Another interesting feature of Sunday evening in Monroe was the big drum.
It appeared that the arrival of the Apostle who was with me had been
expected, and that the people, who are everywhere most curiously on the
alert for spiritual refreshment, had agreed that if the Apostle on arriving felt
equal to holding a meeting, the big drum was to be beaten. In due course,
therefore, a very little man disappeared inside a building and shortly
reappeared in custody of a very big drum, which he proceeded to thump in a
becoming Sabbatical manner. But whether the drum or the association of
old band days overcame him, or whether the devil entered into him or into
the drum, it is certain that he soon drifted into a funereal rendering of
"Yankee Doodle." He was conscious, moreover, of his lapse into weekday
profanity, and seemed to struggle against it by beating ponderous spondees.
But it was of no use. Either the drum or the devil was too big for him, and
the solemn measure kept breaking into patriotic but frivolous trochaics.
Attracted by these proceedings, the youth of the neighbourhood had
collected, and their intelligent aversion to monopolists was soon apparent
by their detaching the little barnacle from his drum and subjecting the
resonant instrument to a most irregular bastinado. They all had a go at it,
both drumsticks at once, and the result was of a very unusual character, as
neither of the performers could hear distinctly what was going on on the
other side of the drum, and each, therefore, worked quite independently. In
the meanwhile some one had procured a concertina, and this, with a dog
that had a fine falsetto bark, constituted a very respectable "band" in point
of noise. Thus equipped, the lads started off to beat up the village, and
working with that enthusiasm which characterizes the self-imposed
missions of youth, were very successful. Everybody came out to their doors
to see what was going on, and having got so far, they then went on to the
meeting. By twos and threes and occasional tens the whole village collected
inside the meeting-house, or round the door unable to get in, and I must
confess that looking round the room, I was surprised at the number of pretty
peasant faces that Monroe can muster.

And here for the first time I became aware of a very significant fact, and
one that well deserves notice, though I have never heard or seen it referred
to—I mean the number of handsome marriageable girls who are unmarried
in the Mormon settlements. Omitting other places, in each of which many
well-grown, comely girls can be found unmarried, I saw in the hamlet of
Monroe enough unwedded charms to make me think that either the resident
polygamist had very bad taste or very bad luck. My host, a Mormon, was a
widower (a complete widower I mean), and two very pretty girls,
neighbours, looked after his household affairs for him. One was a blonde
Scandinavian of Utah birth; the other a dark-haired Scotch lassie emigrated
three years ago—and each was just eighteen. (And in the Western country
eighteen looks three-and-twenty.) I asked my host why he did not marry one
of them, or both, and he told me that he had a family growing up, and that
he had so often seen quarrels and separations result from the remarriage of
fathers that he did not care to risk it.

And the Apostle, who was present, said, "Quite right."

Now please remember this was in polygamous Utah, in a secluded village,


entirely Mormon, where, if anywhere, men and women might surely do as
they pleased. In any monogamous society such a reason, followed by the
approval of a Church dignitary, would not be worth commenting on, but
here among Mormons it was significant enough.

I spoke to the girls, and asked them why they had not married.

"Because the right man has not come along yet," said one.

"But perhaps when the right man does come along he will be married
already," I said.

"And why should that make any difference?" was the reply.

In the meantime each of these shapely daughters of Eve had a "beau" who
took her out riding behind him, escorted her home from meeting, and so
forth. But neither of them had found "the right man."

Of Monroe, therefore, one of those very places, retired from civilization,


"where the polygamous Mormon can carry on his beastly practices
undetected, and therefore unpunished"—as the scandalous clique of Salt
Lake City (utterly ignorant of Mormonism except what it can pick up from
apostates) is so fond of alleging—I can positively state from personal
knowledge that there are both men and women there who are guided in
matters of marriage by the very same motives and principles that regulate
the relation in monogamous society. Further, I can positively state the same
of several other settlements, and judging from these, and from Salt Lake
City, I can assure my readers that the standard of public morality among the
Mormons of Utah is such as the Gentiles among them are either unable or
unwilling to live up to.

In this connexion it is worth noting that public morality has in Utah one
safeguard, over and above all those of other countries, namely, the strict
surveillance of the Church. I have enjoyed while in Utah such exceptional
advantages for arriving at the truth, as both Gentiles and Mormons say have
never been extended to any former writer, and among other facts with
which I have become acquainted is the silent scrutiny into personal
character which the Church maintains.

Profanity, intemperance, immorality, and backbiting are taken quiet note of,
and if persisted in against advice, are punished by a gradual withdrawal of
"fellowship;" and result in what the Gentiles call "apostasy." Among the
standing instructions of the teachers of the wards is this:—

"If persons professing to be members of the Church be guilty of allowing


drunkenness, Sabbath-breaking, profanity, defrauding or backbiting, or any
other kind of wickedness or unrighteous dealing, they should be visited and
their wrong-doing pointed out to them in the spirit of brotherly kindness
and meekness, and be exhorted to repent."

If they do not repent, they find the respect, then the friendship, and finally
the association, of their co-religionists withheld from them, and thus tacitly
ostracized by their own Church, they "apostatize" and carry their vices into
the Gentile camp, and there assist to vilify those who have already
pronounced them unfit to live with honest men or virtuous women.
CHAPTER XV.
AT MONROE.

"Schooling" in the Mormon districts—


Innocence as to whisky, but connoisseurs in
water—"What do you think of that water,
sir?"—Gentile dependents on Mormon
charity—The one-eyed rooster—Notice to
All!

SITTING at the door next morning, I saw a very trimly-dressed damsel of


twenty or thereabouts, coming briskly along under the trees, which there, as
in every other Mormon settlement, shade the side-walk. She was the
schoolmistress, I learned, and very soon her scholars began to pass along. I
had thus an opportunity of observing the curious, happy-go-lucky style in
which "schooling" is carried on, and I was sorry to see it, for Mormonism
stands urgently in need of more education, and it is pure folly to spend half
the revenue of the Territory annually in a school establishment, if the
children and their parents are permitted to suppose that education is
voluntary and a matter of individual whim. Some of the leading members of
the Church are conspicuous defaulters in this matter, and do their families a
gross wrong by setting "the chores" and education before them as being of
equal importance. Even in the highest class of the community children go to
school or stay away almost as they like, and provided a little boy or girl has
the shrewdness to see that he or she can relieve the father or mother from
trouble by being at home to run errands and do little jobs about the house,
they can, I regret to think, regulate the amount of their own schooling as
they please. I know very well that Utah compares very favourably, on paper,
with the greater part of America, but I have compiled and examined too
many educational statistics in my time to have any faith in them.

But in the matter of abstinence from strong drink and stimulants, the leaders
of the Church set an admirable example, and I found it very difficult most
of the time, and quite impossible part of it, to keep my whisky flask
replenished.

My system of arriving at the truth as to the existence of spirit stores in any


particular settlement, was to grumble and complain at having no whisky,
and to exaggerate my regrets at the absence of beer. The courtesy of my
hosts was thus challenged, and of the sincerity of the efforts made to gratify
my barbaric tastes, I could have no doubt whatever. In most cases they were
quite ignorant of even the cost of liquor, and on one occasion a man started
off with a five-dollar piece I had given him to get me "five dollars' worth of
whisky in this bottle," pointing to my flask. I explained to him that I only
wanted the flask replenished, and that there would be change to bring back.
He did not get any at all, however.

On one occasion the Bishop brought in, in evident triumph, two bottles of
beer. On another I went clandestinely with a Mormon, after dark, and drank
some whisky "as a friend," and not as a customer, with another Mormon,
who "generally kept a bottle on hand" for secret consumption. That they
would both have been ashamed for their neighbours to know what they
were about, I am perfectly convinced. On a third occasion an official
brought me half a pint of whisky, and the price was a dollar.

Now it is quite impossible for me, who have thus made personal
experiment, to have any doubt as to the prevailing sobriety of these people.
I put them repeatedly to the severest test that you can apply to a hospitable
man, by asking point-blank for ardent spirits. Sometimes, in an off-hand
way, I would give money and the flask to a lad, and ask him to "run across
to the store and get me a little whisky or brandy." He would take both and
meander round in an aimless sort of way. But I might almost as well have
asked him to go and buy me a few birds-of-paradise or advance sheets of
the "Encyclopaedia Britannica." The father or a neighbour might perhaps
suggest a "likely" place to get some stimulant, but, as a rule, the quest was
unconditionally abandoned as hopeless.

The Elders of the Church set a strict example themselves, discouraging, by


their own abstinence, indulgence even in tea and coffee. You are asked in a
settlement whether you will have tea or coffee, just as in England you
would be asked whether you would drink ale or claret. A strong man takes a
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