Core web application development with PHP and MySQL 1. printing Edition Wandschneider all chapter instant download
Core web application development with PHP and MySQL 1. printing Edition Wandschneider all chapter instant download
https://ebookfinal.com/download/php-and-mysql-web-development-fourth-
edition-thomson/
ebookfinal.com
https://ebookfinal.com/download/php-and-mysql-web-development-second-
edition-welling-l/
ebookfinal.com
https://ebookfinal.com/download/web-application-development-with-yii-
and-php-2nd-revised-ed-edition-jeffrey-winesett/
ebookfinal.com
Build Your Own Database Driven Web Site Using PHP MySQL
4th Edition Kevin Yank
https://ebookfinal.com/download/build-your-own-database-driven-web-
site-using-php-mysql-4th-edition-kevin-yank/
ebookfinal.com
Learning PHP MySQL JavaScript and CSS 2nd Edition Robin
Nixon
https://ebookfinal.com/download/learning-php-mysql-javascript-and-
css-2nd-edition-robin-nixon/
ebookfinal.com
https://ebookfinal.com/download/learning-php-mysql-step-by-step-guide-
to-creating-database-driven-web-sites-second-edition-michele-e-davis/
ebookfinal.com
https://ebookfinal.com/download/learning-php-mysql-javascript-with-
jquery-css-html5-early-release-5th-5th-edition-robin-nixon/
ebookfinal.com
https://ebookfinal.com/download/php-mysql-the-missing-manual-second-
edition-brett-mclaughlin/
ebookfinal.com
MARC WANDSCHNEIDER
ISBN 0-13-186716-4
Text printed in the United States on recycled paper at R.R. Donnelly in Crawfordsville, IN.
First printing, September 2006
Contents
Introduction xxiii
Target Audience xxiii
About PHP xxiv
Layout xxiv
Before You Begin xxv
Acknowledgments xxv
In Closing xxvi
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
V
Contents
vi
Unicode 135
Unicode Encodings 136
Making Sense of It All in PHP 136
Working with Other Character Sets 136
Trouble Rears Its Ugly Head 138
How We Will Work with Characters 139
Configuring PHP for Unicode 140
Installation and Configuration of mbstring and mbregex 140
Function Overloading 141
Operating on Strings 141
Getting Information 141
Cleaning Up Strings 143
Searching and Comparing 144
Extraction 148
Case Manipulation 149
Character Encoding Conversions 150
Summary 150
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
PART VI Appendixes
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■
Index 825
This page intentionally left blank
Introduction
T his is the book I wish I had a couple years ago when I sat down and decided to
learn something about web applications. The transition from programming standard
window-system GUI applications to writing dynamic web applications was surprisingly
complicated. Extremely productive languages, such as Personal Home Page (PHP), make
the transition easier, but the learning curve remains steep.
With that in mind, I sat down to write this book and explain how to use the various tech-
nologies that go into writing web applications. I have made every mistake possible while
learning about PHP and databases, and have therefore tried to incorporate as much of
what I learned into this book. Far too many books published these days are merely a
reprint of existing documentation or Unix man pages, and I truly wanted to see something
different in print.
The technologies, however, are only half the battle. Without strategies or systematic
approaches to design and implementation, applications are doomed to an expensive
and messy existence at best—or failure at worst. Therefore, this book focuses on a lot of
things you might not see covered to the same extent in other books—design, testing, and
security.
Target Audience
This book is targeted at people who need or want to write a web application. You might
be a corporate developer looking to build an intranet application for your company or an
xxiii
Core Web Application Development with PHP and MySQL
xxiv
Internet web application for customers. You might be a consultant helping a small busi-
ness develop a web store, or just a hobbyist looking to learn more about web applications
and write one of your own.
The assumption is that you have at least a passing familiarity with programming,
although this book by no means expects you to be an expert. An understanding of basic
programming constructs, such as variables and functions, and a basic understanding of
HTML should be more than sufficient.
Because I knew next to nothing about databases when I started learning about web appli-
cation programming, I likewise expect no more of the reader. This book covers databases
from basic terminology and design to basic and advanced queries, with an appropriate
balance between clear-and-simple instruction and interesting examples to help you in
your development.
About PHP
PHP began in 1994 as a series of scripts called PHP/FI (Personal Home Page/Forms
Interpreter), and it was written by a fellow named Rasmus Lerdorf to help him manage
documents on his web site. Over the years, PHP grew into something more serious. In
1997, a second version of the system came out with additional functionality.
In late 1998, PHP 3.0 was released, leading to a major rewrite of the code and the involve-
ment of two new developers—Zeev Suraski and Andi Gutmans. The goal was to support
progressively broader and more complex applications on the web. In early 2000, version
4.0 was released. Based on a new language engine called the Zend Engine, this version
had much better performance and increased code modularity. By late 2004, the much-
evolved version 5.0 was released. It included many new features, such as new language
constructs, broader web server support, sessions, and additional third-party extensions.
Among the new language features was a significantly improved and expanded object-
oriented programming model, which this book uses extensively. Somewhere along the
way, PHP ceased to refer to “Personal Home Page” and came to mean “PHP Hypertext
Preprocessor,” a so-called recursive acronym. (The acronym actually forms part of the
term it defines!)
PHP is a remarkably productive language—you can sit down and crank out (yes, that’s
the technical term) large amounts of code in a short period of time, and this productivity
is what drew me to it some years back. With PHP, I was able to put together surprisingly
robust and dynamic travelogues of my journeys to various countries with relatively little
code.
The one possible “fly in the ointment” is that the language can be quirky compared to
other programming languages—especially if you, like me, come from a background of
languages more similar to C/C++, Java, or Visual BASIC. In fact, many of the things cov-
ered in this book are the result of my sitting around and scratching my head for a couple
of hours. However, after you become comfortable with it, the language proves fun to
write and is surprisingly powerful.
Layout
This book is divided into six parts, which represents the logical progression of writing
web applications.
Part I, “The Basics of PHP,” covers the PHP language itself, starting with descriptions
and discussions of the most basic types of language. Part I then moves on to functions,
Introduction • Acknowledgments
xv
Acknowledgments
I would like to thank the Academy for all the wonderful…gosh…I mean…what a rush!
Oh wait, wrong speech.
In all seriousness, no book can be written without a lot of help, and this is no exception.
Prentice Hall and my editor Mark Taub both deserve a huge amount of thanks for help-
ing me realize a dream and working with me on this book. The freedom and opportunity
to write the book I wanted to write were never threatened, and they have been amazing
at answering questions as I sent them.
Core Web Application Development with PHP and MySQL
xxvi
The technical review team of Kristine Kuch, Matthew Leingang, and Kimberly Jenson are
owed a huge debt of thanks. Never afraid to call me on stupid mistakes or bad writing or
short with praise and compliments, these people have taught me tons and have helped
me grow as both a web applications programmer and author over the past six months.
Finally, none of this would be possible without the support of my wife Samantha, who
encouraged me repeatedly to do more writing in the first place and lovingly nudged me
on those evenings when I swore I would never look at another computer again and was
sick of typing.
In Closing
I hope that you enjoy reading this book. I certainly hope that it helps you in your web
application programming endeavours and also provides at least some reading enjoyment.
I am a terribly chatty person, and always love to hear from people; therefore, if you have
any comments on the book or suggestions of things to add or treat differently, I’d be
delighted to hear from you at marcwan@chipmunkninja.com.
PART I
The Basics
of PHP
This page intentionally left blank
1
Getting Started
with PHP
B y now, you have managed to get PHP running on your server or workstation and
are ready to start writing scripts in PHP. If you have not, or you are still having problems,
please see Appendix A, “Installation/Configuration,” for more details. In this chapter, we
are going to write our first programs using Personal Home Page (PHP), and learn about the
basics of working with the language.
Over the course of this chapter we will
• Write a few basic PHP programs and learn how to enter and process PHP scripts
• See the basics of how the language is structured and how to comment your code
• Learn about some of the more common and basic data types in PHP
• Learn about some useful functions that we will use throughout this book
3
Core Web Application Development with PHP and MySQL
4
When the web server receives a request for an appropriately named file, it passes this to
the PHP engine, which then processes the file one line at a time. For lines that do not
contain PHP code (typically, lines containing HTML markup), the server emits them
untouched and executes any PHP script code as it is seen. With this in mind, we write
our first program, which is a mixture of PHP and HTML.
<html>
<head>
<title>My First PHP Program</title>
</head>
<body>
<?php
echo "Hello Everybody!";
?>
</body>
</html>
If we type this into a file called firstprogram.php and put it in our document root directory,
we can then type the URL for the path to this file (for example, http://localhost/
gettingstarted/firstprogram.php). We should then see something similar to Figure 1-1.
If you have problems getting the script to run correctly, here are a few things you should
investigate:
• Make sure you entered the URL to the script file correctly, making sure that the server
name is valid.
Do not forget that the path gettingstarted is relative to the document root directory
for the web site. So, if our web site’s root directory were c:\inetpub\wwwroot or
/home/samplesite/www, then our directory in the preceding example would be
c:\inetpub\wwwroot\gettingstarted or /home/httpd/www/gettingstarted.
1 • Your First PHP Programs
5
• If you see just the code of your script printed onscreen, chances are that your web
server has not been configured to recognize .php files as needing to be sent to the PHP
interpreter.
• If you get an error saying that the host could not be found, then you should make sure
that the web server is actually running. See Appendix A for more information.
Most of the file is simply HTML text. As we have said, the PHP language engine outputs
any text it sees and looks for PHP code sections. In the preceding file, the PHP code is
demarcated by the tags
<?php
...
?>
When the PHP language engine sees these two tags, it processes the script and takes any
appropriate actions. When the script portion ends, it resumes output of HTML.
To learn more about our PHP installation, we will write a small script in our next program
that uses a helpful little tool. This function, called phpinfo, is used as follows:
<?php
phpinfo();
?>
This script produces output similar to that seen in Figure 1-2. (We did not have to use
HTML headers or markup since the phpinfo function emits these for us.)
Figure 1-2: Learning about our PHP interpreter with the phpinfo() function.
Core Web Application Development with PHP and MySQL
6
This method is safe for both XHTML and XML files; therefore, it is the method we will use
throughout this book.
Another way to demarcate PHP script is as follows:
<?
echo "Bonjour tout le monde!";
?>
This is called using short tags. Short tags are available only if the short_open_tag setting
is enabled in your php.ini configuration file (see Appendix A). The use of this style is gen-
erally discouraged, as it does not save you much in typing and can create problems as you
move your code from server to server, where one of them might not have short tags
enabled.
A third way of entering script is
<script language="php">
echo "Ciao a tutti!";
</script>
This method does not buy us very much and is generally used much less than the first
style.
One final style of inputting script exists to support some older graphical HTML editing
programs that are unable to understand script directives very well and would move script
around when they generated HTML for user input. However, some of these editors could
support tags by marking code as ASP script. To let users continue to use these editors, you
can mark PHP script using these ASP tags:
<%
echo "Guten Tag alle!";
%>
ASP tags can only be used if the asp_tags setting is enabled in the php.ini configuration
file.
Even though we will use the first style of tags, we have shown you all the possible types
to prepare you for other codes you may encounter.
you might want to personalize a greeting message ($userName is a variable, which we will
introduce more formally soon):
<?php
$userName = "Chippy the Chipmunk";
?>
<p align='left'>
Hello there, <b><?php echo $userName; ?></b>
</p>
A shortcut exists for this particular usage. It involves the short tags discussed in the previ-
ous section along with an equals sign (=):
<?= $userName ?>
This is the same as typing
<?php echo expression; ?>
This can be a handy way to save a bit of typing when you are injecting several expressions
into your HTML. However, we will continue to avoid using short tags and stick with the
normal syntax.
The flexibility available when mixing PHP and HTML allows us to be creative when we
get into more advanced language constructs. (These concepts will be introduced in
Chapter 2, “The PHP Language.”)
<?php
?>
This, like some other things we will encounter as we learn about web application pro-
gramming with PHP—while perfectly valid in PHP—is probably something we should
Core Web Application Development with PHP and MySQL
8
use sparingly. We should write code that is legible and easily maintainable whenever
possible.
{
echo "This is a group of statements";
$m = "oink";
}
$userName
=
"Chippy the Chipmunk"
;
?>
Just because one can do this, however, does not mean it is recommended. Programmers
are always encouraged to make their code legible.
The end of a section of PHP script is also a valid way to terminate a statement:
<?php echo "Semi-colon not necessary here!" ?>
//
// This is our second style of comment. It is "single line"
//
echo "Style 2";
#
# This third style is also "single line."
1 • How to Store Data
9
#
echo "Style 3";
?>
The first two styles are very common in higher-level programming languages, such as
C/C++, Java, and C#, while the latter style will be familiar to programmers of Perl and
shell scripts.
The first style of comments beginning with “/*” causes the PHP processor to ignore all
text until it sees a closing “*/” sequence. This can cause problems if you try to nest
comments.
<?php
/*
/**
* this is a comment.
*/
echo "This is some code";
*/
?>
Because of the nested comment, the processor stops treating the code as comment text at
the first “*/” token and reports and error at the second, because it no longer believes itself
to be processing comments.
The two types of single-line comments cause the PHP language processor to ignore all
code until the end of the current line or current PHP script section.
<?php
// all of this line is ignored.
echo "But this line prints just fine.";
?>
In versions of PHP prior to version 4, variables would be declared at their first use instead
of their first assignment, which often proved tricky when debugging code.
<?php
?>
Fortunately, PHP 5 prints a warning saying that, for instance, "$ceiling” has not been
assigned a value.
Numbers
There are two basic types of numbers in the language: integer (int ) and float (float).
While many languages distinguish between single and double-precision floating-point
numbers, PHP does not—they are all 64-bit floating-point numbers with approximately 14
digits of precision. PHP does, however, support the keyword double in addition to float
for compatibility.
Integers are specified in code in octal (base-8), decimal (base-10), or hexadecimal (base-16)
notations.
<?php
?>
1 • Entering Basic Types in PHP
11
Integer precision varies largely by the underlying operating system, but 32 bits is com-
mon. There are no unsigned integers in PHP, so the maximum value for an integer is
typically larger than 2 billion. However, unlike other languages that overflow large
positive integers into large negative integers, PHP actually overflows integers to floating-
point numbers.
<?php
$large = 2147483647;
var_dump($large);
$large = $large + 1;
var_dump($large)
?>
In the previous snippet of code, we introduce the var_dump function, a powerful debug-
ging tool used to see both the type and value of a variable in PHP. We will return to this
later in the chapter in the section titled “Some Very Useful Functions.”
Even though we will discuss arithmetic operators such as addition, multiplication, and
subtraction in Chapter 2, in the section titled “Expressions and Operators,” we will take
time now to note that there is no integer division in PHP. Unlike some other languages,
for which the expression
5 / 2
would yield an integer result with the value 2, PHP would return the value 2.5, typed as
float. If you want the integer value result of a division operation, you need to cast the
value to an integer (see the section “Type Conversions” in Chapter 2) or use the round
function, which you can learn about via the PHP Online Manual.
Floating-point variables can be input in a few different ways:
<?php
$floatvar1 = 7.555;
$floatvar2 = 6.43e2; // same as 643.0
$floatvar3 = 1.3e+4; // same as 13000.0;
$floatvar4 = 5.555e-4; // same as 0.0005555;
$floatvar5 = 1000000000000; // too big for int ==> float
?>
One caution with floating-point numbers: Remember that they are only approximate val-
ues. Because of their limited precision, they are very close to the intended value but are
not always the value you would like.
Core Web Application Development with PHP and MySQL
12
For example, the value 2.5 will often be represented internally as 2.4999999999, or some-
thing similar. Thus, the following code will often prove problematic:
<?php
?>
Code snippets such as these often print "What???", depending on the exact implementa-
tion of floating-point numbers.
The recommendation is to avoid comparing specific floating-point values. Instead, you
should round them to the nearest integer value using round, or compare them against the
ranges of values.
Strings
A string is a sequence of characters. In PHP, these characters are 8-bit values. This is con-
venient for many Western languages but proves a bit problematic when trying to work
with systems using more complicated alphabets, such as Chinese. We will cover solutions
for this in more detail in Chapter 6, “Strings and Characters of the World.”
There are three ways to specify a string value.
Single Quoted
Single-quoted strings are sequences of characters that begin and end with a single quote (').
<?php echo 'This is a single-quoted string.'; ?>
To include a single quote within a string, you simply put a backslash in front of it. This is
called escaping the character.
<?php echo 'This is a single-quoted (\') string.'; ?>
If you actually want to print \' as output or if you want to end a string with a backslash
character, then you need to escape the backslash one more time.
<?php
?>
1 • Entering Basic Types in PHP
13
Escape Output
\n Linefeed character (0x0a/10 in ASCII)
\r Carriage return character (0x0d/13 in ASCII)
\t Tab character
\\ Backslash
\$ Dollar sign character
\0octal-number A character identified by its value in the range 0–255,
specified in octal notation.
\xhexadecimal-number A character identified by its value on the range 0–255,
specified in hexadecimal notation.
No other escape sequences are supported, and (in the case of single-quoted strings) non-
matching sequences will simply print the backslash and the other character.
<?php
echo "This is a rich \"\$\$\" double-quoted string.";
echo "<br/>\n";
echo "This is a rich \042\x24\x24\042 double-quoted string.";
echo "<br/>\n";
echo "This won't quite do what \n\n you expect it to!";
echo "<br/>\n";
echo "Neither likely
will
this.";
echo "<br/>\n";
echo "\\ + A isn't a valid escape, so this will print \A";
?>
Exploring the Variety of Random
Documents with Different Content
“But ladies are more apt to be at home early in the morning,” urged
Molly, who was anxious to have the adventure begin. “Besides, it’s
getting hot, and we’re all thirsty. What are you going to do about a
reference? I’ve heard Grandma say she would never engage a girl
who didn’t have a good reference.”
Dulcie looked a little startled. She had not thought of the necessity of
references. But just then Maud put in an anxious question.
“Suppose nobody wants us, and night comes, where are we going to
sleep?”
“Don’t talk about night when it’s only just about breakfast time,”
reproved Molly. “We’ll be sure to find a place long before dinner-time,
and I don’t believe, when the people know who we are, they’ll make
us eat in the kitchen. I think we shall be kind of lady helps, like
Phœbe in ‘Eight Cousins.’ Phœbe did the cooking, but she had
lovely times, too, don’t you remember?”
“But Dulcie says we mustn’t let people know our real names,” Maud
reminded her, “so I don’t see how they can find out who we are.”
“Well, it’s going to be fun, anyhow,” maintained Molly, cheerfully. “I
wouldn’t go home again for anything, after coming so far, and
spending all that money, would you, Dulcie?”
“Of course not,” said Dulcie, “and I suppose, after all, we might as
well begin with this house as any other. But you mustn’t be
disappointed if we have to try a good many places before we find
any one who wants us. And—and there’s another thing; I don’t
believe we’d better all go in together. They might get discouraged if
they saw there were so many of us.”
“But they’ll have to know as soon as they engage us,” objected
Daisy.
“Of course they will, but they needn’t find out the very first minute. I
think the best way will be for you and me to go first, and then, if the
people seem kind, and want us to stay, we can explain about the
others. Molly and Maud can wait for us right here, under that big
tree. We won’t be gone long.”
Daisy still looked very doubtful, and Maud began to object to being
left behind, but Dulcie was firm, and Molly also proved equal to the
occasion. So the question was settled, and the two younger children
comfortably ensconced under a big apple-tree, while Dulcie and
Daisy walked up the wide gravelled path to the house. It was not a
large house, but a very pretty one. There was a lawn, with flower
beds in front, and the children caught glimpses of a stable and other
outbuildings in the rear. There was no one to be seen, but as they
approached the house, the sound of a piano could be distinctly
heard.
“Somebody’s practising exercises,” whispered Dulcie. “Perhaps it’s
the lady of the house.”
“There’s a doll’s carriage on the piazza,” said Daisy, “so there must
be a little girl.”
“I’m glad,” said Dulcie, with a great effort to speak cheerfully. “If the
people have a little girl of their own, it may make them kinder to other
little girls. I’ve been thinking about our names. I don’t want to change
them any more than I can help; it doesn’t seem quite honest. I don’t
see how I can very well change Dulcie into anything but Delia, but
you can be Margaret, which is your real name, anyhow, and Molly
can be Mary. I’ll have to decide about Maud later, but I think our last
name had better be Smith. When people in books change their
names, they nearly always call themselves Smith or Brown.”
Daisy opened her lips to protest, but at that moment the sound of the
piano ceased, and in another moment the front door opened, and a
very pretty little girl of eight or nine came out onto the piazza. She
was so pretty that Dulcie and Daisy stopped short in the path, and
stood gazing at her in undisguised admiration. She had big brown
eyes, and long golden curls, and she was dressed in white, and wore
a string of gold beads round her neck. Altogether, she looked so
much like the picture of a little princess in one of their fairy books
that Dulcie and Daisy fairly gasped.
As for the stranger herself, she did not seem in the least surprised,
but smiled a bright, welcoming smile, and came running down the
steps to greet the visitors.
“Oh, I’m so glad you’ve come,” she cried, joyfully. “Mamma said she
thought you might come to-day, but I didn’t expect you quite so early.
It’s all right, though; I’ve finished my practicing. I did a whole half-
hour since breakfast. Mamma says that’s quite enough in summer.
Won’t you come up on the piazza?”
To say that the two little Winslows were surprised at the cordiality of
this greeting would be but a poor way of expressing their feelings.
Indeed, they were so much astonished as to be, for the first moment,
quite deprived of the power of speech. Then Dulcie found her voice,
and managed to gasp out:
“You—you were expecting us!”
“I wasn’t exactly expecting you,” the stranger explained, “because
your mother didn’t positively tell Mamma you would come to-day, but
I hoped you would, because I don’t know any of the children here
yet, and I’m so anxious to have somebody to play with.”
“I think you must be making a mistake about us,” said Daisy, who
was beginning to grasp the situation. “Who do you think we are?”
“Why, aren’t you the two little Baxter girls? Mrs. Baxter came to call
on Mamma yesterday, and she said she would send her two little
girls over to play with me, so when I saw you, of course I thought I
knew who you were. It doesn’t really make any difference, though,
for I’ve never seen the Baxters, and I shall probably like you just as
much. You see, Papa has only taken this house for the summer, and
we didn’t come till last Monday, so I don’t know any of the children
who live here. What are your names, and which house do you live
in?”
Daisy was silent, and Dulcie flushed a little as she answered.
“Our name is Smith. I’m Delia Smith, and this is my sister Margaret.
We don’t live here, and we—we didn’t exactly come to see you. We’d
like to speak to your mother.”
The little girl’s face fell.
“I’m very sorry,” she said, “I hoped you had come to play with me.
Mamma has gone to the station with Papa, but she won’t be gone
very long. I hope you can wait.”
“We can wait,” said Dulcie. She had taken a fancy to the pretty little
girl, and was hoping that her mother might prove as friendly as
herself.
The child looked pleased.
“All right,” she said, hospitably, “and while you’re waiting, perhaps
you’d like to come and see the rabbits. They’re very cunning, and it’s
about time I gave them their breakfast.”
The prospect of feeding rabbits was very alluring, but Dulcie was
mindful of the importance of maintaining her dignity. People looking
for situations ought not to waste their time on anything so trivial as
rabbits.
“I think perhaps we’d better wait here,” she said. “Do you happen to
know whether your mother needs any help?”
“Help,” repeated the little girl, rather vaguely, “what kind of help?”
“Oh, help in the house, or—or in the garden. Any kind that little girls
could do. I thought she might want some one to wash the dishes, or
make the beds, or——”
“Oh, you mean a maid,” interrupted her new acquaintance, with
sudden comprehension. “No, I’m sure Mamma doesn’t need any
one. I heard her tell Papa all the servants were very satisfactory.
What made you want to know?”
“Because we—oh, it doesn’t matter. I’m afraid there isn’t any use of
our waiting to see your mother, after all.”
“Oh, please don’t go so soon,” pleaded the little girl, clasping her
hands imploringly. “You’ve only just come, and I do want somebody
to play with so much. Wait and see Mamma; you’ll love her, and
perhaps she knows some lady who wants a maid. I suppose your
mother wants to find a place for one, just as Mamma did when we
went to Europe last year. Don’t you really think you’d like to come
and see the rabbits?”
“I’m sorry, but I’m afraid we can’t,” interposed Daisy, firmly. “We’ve
left our—some people waiting for us on the road, and they might get
worried if we stay away too long.”
“It will only take a few minutes to see the rabbits,” their new friend
urged, “and Mamma will be back very soon. Do you think those
people would mind waiting just a little longer?”
Dulcie wavered. The little girl was so cordial; it seemed almost rude
to refuse her invitation. She glanced appealingly at Daisy.
“I think we might stay just a few minutes,” Daisy agreed. She loved
pets, and to possess rabbits had long been an unfulfilled dream.
So the question was settled, and five minutes later three very eager
little girls were bending lovingly over a family of soft, wriggling baby
rabbits.
“They’re the cunningest things I ever saw,” declared Daisy, pressing
one downy mite to her cheek. “I do wish Molly and Maud could see
them.”
“Who are Molly and Maud?” inquired her new friend, with interest.
Daisy started and flushed. In the interest of the moment she had
quite forgotten the rôle of Margaret Smith.
“They are our two sisters,” she explained, with an apologetic glance
at Dulcie. “We all love rabbits, but Grandma will never let us have
any pets.”
“You must bring them to see my rabbits,” her hostess said politely.
“I’ve got so many, I’d like to give you some, if your grandma would let
you have them.”
“You are very kind,” said Dulcie, “but I’m afraid we couldn’t take
them. You see, we don’t expect to live at home any longer.”
The brown eyes opened very wide, and their new acquaintance
inquired in a tone of the utmost astonishment:
“Where are you going to live, then?”
“We don’t know,” said Dulcie; “that’s what we wanted to speak to
your mother about. We are looking for a situation.”
Their new friend gasped.
“But you’re not grown up; you’re only little girls,” she faltered. “Little
girls only work if their mothers are very poor. You don’t look a bit like
poor people.”
“We’re not exactly poor,” Dulcie explained, “but there are—reasons
why we don’t want to live at home any more, so we’ve come away to
try to find a situation. We don’t mind working hard, and there are
really a good many things we can do. We’ve made our own beds
and dusted our rooms ever since Liz—I mean for quite a long time,
and we can wash dishes, and cook a little, too. If we could have a
cook-book, I think we would manage very well.”
The look in the little stranger’s eyes had changed from astonishment
to admiration.
“I think you are very clever,” she said. “I wish I could do useful things
like that, but I shouldn’t like to leave my home. I think I should die if I
had to go away from Mamma and Papa.”
“I’m sure you will never have to do it,” Dulcie reassured her. “You
see, it’s quite different with us. Our mamma is dead, and our papa—
oh, well, we’d rather not talk about it, but it’s all very sad, and we
don’t want to be burdens any longer. Let’s talk some more about the
rabbits.”
Their new friend nodded comprehendingly.
“I know how you feel,” she said. “I hate talking about sad things, too.
I don’t like sad stories, either. Once Mamma read me about little Paul
Dombey, and I cried so much I had a headache.”
“I wish we had a mamma,” said Daisy, with a sigh. “Children are
never burdens to their mothers. I think yours must be nice; you talk
so much about her.”
“She’s the loveliest lady in the world. She’s so good that everybody
loves her. Haven’t you ever heard about her?”
“No, I don’t think we have,” Daisy admitted reluctantly. “You see, we
don’t know very many people. What’s your mamma’s name?”
“Mrs. Richard B. Thorne, and I am Barbara Muriel Thorne.”
“Oh, what a beautiful name!” cried Dulcie. “I’ve read about Barbaras,
but I never met one before. I wish my name was Barbara, or else
Gladys. Muriel is quite a book name, too.”
“Yes, they are pretty names,” Barbara Muriel answered, with some
pride. “But Delia is rather a nice name, too,” she added, politely.
“I think it’s about the ugliest name I ever heard,” said Dulcie. “I can’t
think what made me choose it.”
Barbara looked rather puzzled.
“I didn’t know people ever chose their own names,” she said. “Are
you Baptists?”
“Oh, no,” said Dulcie, blushing; “we are Episcopalians. What made
you think we were Baptists?”
“Because Hannah said Baptists weren’t baptized till they were grown
up, and I thought perhaps they chose their own names, instead of
having them given to them, when they were babies.”
Dulcie was beginning to feel rather uncomfortable, but fortunately, at
that moment, Daisy came to her rescue.
“Hark!” she exclaimed, eagerly; “I think I hear a carriage. Perhaps it’s
Barbara’s mother.”
Barbara ran to look, and returned in a moment with the joyful
intelligence that it was Mamma coming home.
“She’s just driving round to the front door,” she said. “I’ll run ahead,
and tell her about you.” And away she flew, followed more slowly by
her two companions.
“I—I feel just like running away,” faltered Daisy. “Oh, Dulcie, let’s go.
It all seems so very—queer.”
“We can’t run away now,” said Dulcie, and her tone was decided,
though her teeth were beginning to chatter. “It wouldn’t be polite, and
besides, I think perhaps Barbara’s mother may understand, and be
kind to us.”
CHAPTER XVII
STEPMOTHERS
AS the children approached the house they saw that a pony phaeton
was standing by the front steps, out of which a lady had just alighted.
She was speaking to the groom, who had run up from the stable to
take the horse, but at the sound of Barbara’s voice she turned to
greet her little daughter, and even at that first glimpse Dulcie and
Daisy could see that she had a very sweet face.
“Mamma,” cried Barbara, reaching her mother’s side in a rather
breathless condition, “here are two little girls who want to see you.
Their names are Delia and Margaret Smith. The biggest one is Delia;
she chose her name herself, and the littlest one is Margaret.”
Mrs. Thorne greeted the visitors very kindly.
“I am glad Barbara has found some little friends,” she said. “Suppose
we all come into the house. It is rather warm, and I would like to take
off my hat before doing anything else.”
“We’re—we’re looking for a situation.”—Page 259.
Her voice was so kind and cordial, and her smile so pleasant, that
Dulcie and Daisy were both conscious of a sensation of decided
relief. Still, the situation remained an embarrassing one, for it was
quite evident that Mrs. Thorne supposed them to be some little
neighbors come to make a morning call. However, there was nothing
to be done but to follow Barbara and her mother into the house, and
then they found themselves in a cool, flower-scented room, and Mrs.
Thorne was saying in her bright, friendly voice:
“I am sorry you had such a hot morning for your walk. I hope you did
not have far to come.”
“We—we don’t live here,” stammered Dulcie, her cheeks growing
suddenly very hot. “We came in the train, and walked up from the
station.”
“You came on the train?” Mrs. Thorne repeated, incredulously. “You
don’t mean by yourselves?”
“Oh, yes,” said Dulcie. “You see, we had to. We’re—we’re looking for
a situation.”
Mrs. Thorne gazed in growing bewilderment from one serious little
face to the other.
“A situation,” she gasped. “Why, you are only children.”
“I’m twelve,” said Dulcie, rather tremulously, “and Dais—I mean
Margaret, is eleven. Of course we wouldn’t expect to be paid very
much at first.”
“But I don’t understand. Why do you want to work at all? You are not
poor children.”
That was just what Barbara had said, and Dulcie felt her heart sink.
How could they ever explain the situation without telling the whole
story?
“We’ve gone away, because we don’t want to be burdens to our
stepmother,” put in Daisy, coming to her sister’s relief.
A shadow crossed Mrs. Thorne’s sweet face, and as if instinctively,
she slipped an arm round Barbara, who was standing by her side.
“Don’t you love your stepmother?” she asked, gently. “Isn’t she kind
to you?”
“We’ve never seen her,” Daisy explained. “She’s only coming to-day.
Papa married her in California, and we never knew anything about it
till yesterday. We are sure she won’t want us, and we are very tired
of being burdens to people, so we came away to earn our own
livings.”
Daisy paused abruptly, and two big tears rolled slowly down her
cheeks.
Mrs. Thorne was really wonderful. She seemed to understand the
whole situation at once, without asking another question.
“You poor little chicks,” she said, and her voice was so kind that,
instead of checking Daisy’s tears, it caused her to cry all the more.
And then somehow, they were all on the sofa together, and Mrs.
Thorne had one arm round Daisy, and the other round Dulcie—who
had also begun to cry—and Barbara was looking on, with tears of
sympathy in her own eyes.
“We love our papa very much indeed,” sobbed Dulcie, “but we think
perhaps he will be glad to have us go away, on account of the
stepmother, you know. I promised Mamma before she died that I
would always take care of the others, and stepmothers are so very
cruel sometimes.”
“There, there, dear,” soothed Mrs. Thorne, “don’t try to talk any more
till you feel better. I think I understand everything. You have made a
foolish mistake, but it’s going to be all right.”
There was something wonderfully reassuring in that kind, cheerful
voice, and in a few minutes the two little girls had dried their tears,
and were beginning to feel almost cheerful themselves. But now a
new difficulty arose; something that neither of them had ever thought
of. In their absorption they had quite failed to notice that the hot
sunshine had been suddenly obscured by a dark cloud, until
suddenly the rumble of distant thunder fell upon their ears. Daisy
was on her feet in a moment.
“There’s going to be a thunder-storm!” she exclaimed. “We must go
right after Molly and Maud. Maud hates thunder.”
“Who are Molly and Maud?” inquired Mrs. Thorne, and, as if in
answer to her question, there was a sound of little feet on the piazza,
and through the open window came an anxious voice.
“Dulcie, Daisy, where are you? There’s a horrid thunder-storm
coming up.”
“They are our two little sisters,” explained Dulcie. “We left them out
on the road. We were afraid people wouldn’t take us if they saw how
many there were. Would you mind very much if they came in, just till
the shower is over? Maud is so afraid of thunder-storms.”
“Certainly not,” said Mrs. Thorne, who was beginning to look very
much amused. “Run and bring the little girls in, Barbara.”
Away flew hospitable Barbara, closely followed by Dulcie and Daisy,
and in another moment they were back again, accompanied by Molly
and Maud, who both looked very red and uncomfortable.
“It was all Maud’s fault,” Molly was whispering apologetically to
Dulcie. “I wanted to wait, but the minute she heard the thunder she
was frightened, and she cried so hard I had to let her come to find
you.”
“It was beginning to thunder,” Maud was at the same moment
explaining to the sympathetic Barbara. “Dulcie and Daisy stayed
away so long, and I was so thirsty. I thought I was going to like cake
for breakfast, but I didn’t; it left such a funny taste afterwards.”
“Dulcie and Daisy,” repeated Barbara; “why, I thought their names
were Delia and Margaret.”
Maud looked blank, and Dulcie, blushing furiously, but still with a
desperate attempt to keep up their assumed characters, hastened to
explain.
“Dulcie and Daisy are our home names,” she said. “Daisy’s real
name is Margaret.”
“And your real name is Delia, I suppose,” said Mrs. Thorne, smiling;
“Delia Smith, I think you said.”
Dulcie was silent. She was a truthful child, and not even for the
honor of the Winslow family could she bring herself to tell a
deliberate lie. Mrs. Thorne seemed to understand, for she smiled
again, and her voice was very kind.
“Barbara darling,” she said, “suppose you take Molly and Maud into
the dining-room, and get them each a glass of milk. Maud says she
is thirsty, and cake is hardly a substantial breakfast. Ask Jane to boil
some eggs, and warm some oatmeal, and we will all come in a few
minutes. Now, my dear little girls,” she added in a graver tone, when
the three younger children had left the room, “I want you to tell me
your real names, and where you live. I must let your family know
where you are as soon as possible. They are probably frightened to
death about you already.”
Dulcie clasped her hands in despair, as she saw the last hope of
carrying out her wonderful plan of independence fading from her
grasp. But there was an air of gentle determination about Mrs.
Thorne that convinced her of the uselessness of a refusal. She
answered meekly:
“My name is Dulcie Winslow and my sister is really Margaret, but
every one calls her Daisy. We live at Tarrytown with our
grandmother, and——”
“You don’t mean to tell me you are old Dr. Winslow’s grandchildren!”
interrupted Mrs. Thorne, in a tone of genuine astonishment.
Dulcie nodded, and Daisy asked timidly:
“Did you know our grandfather?”
“I used to see him often when I was a little girl. We were neighbors in
New York, and his son Jim was a great friend of mine.”
“Why, that’s our papa!” cried Dulcie, shame and disappointment alike
forgotten in the excitement of this discovery. “How wonderful to think
you knew Papa. Perhaps you knew Mamma, too.”
“No, I never saw your father after he went to college, but we were
great friends as children. He was a very nice boy.”
“He’s the loveliest man in the world,” declared Daisy, with shining
eyes.
Mrs. Thorne smiled.
“Is he indeed?” she said. “One would hardly think you were so fond
of him when you have been trying to run away from him.”
“Oh, we weren’t running away from Papa,” cried Dulcie, quite
horrified at the suggestion. “We love him better than any one else in
the world, and we were so happy when we knew he was coming
home from China, but then we heard about the stepmother, and I
thought—I was afraid——” Dulcie paused in hopeless confusion.
“We didn’t want to be incumbrances,” said Daisy. “Aunt Julia Chester
said we were incumbrances to Grandma. Dulcie looked up the word
in the dictionary, and it means the same thing as being a burden.
Dulcie thought we might be able to work for our living, even if we
were only little girls, and so——”
“And so you ran away, like two very foolish children, and took your
younger sisters with you. I suppose it never occurred to you how
unhappy you would make your father.”
At this awful suggestion both little girls began to cry.
“I—I thought he would be proud of us,” sobbed Dulcie. “I wouldn’t
make Papa unhappy for the whole world.”
“There, there, dear, don’t cry; I knew you wouldn’t.” And Mrs. Thorne
put a kind arm round the trembling child. “You thought you were
doing something very fine, and now you are going to do something
much finer, by going home again, and showing your papa that you
trust him, and feel sure he would not do anything to make you
unhappy. As for the stepmother; all stepmothers are not wicked.
There are many who love their stepchildren dearly. Perhaps your
stepmother is longing to know you, and to make you love her. I doubt
very much that she has ever thought of you as incumbrances. Now I
think breakfast must be ready, so dry your eyes, and we will join the
others in the dining-room.”
That was a wonderful morning; the children never forgot it. To Molly
and Maud it was a morning of pure delight, and even their elder
sisters, in spite of several causes for anxiety, could not help enjoying
themselves, whenever they forgot to think about the future. Mrs.
Thorne was very kind to them all, and Barbara proved a delightful
little hostess. The shower was a very slight one, and by the time they
had finished breakfast, the sun was shining once more. Mrs. Thorne
went out in the pony phaeton again, and Dulcie and Daisy had an
uncomfortable conviction that her errand was in some way
connected with their affairs. Nothing, however, was said about their
going home at once, and Barbara took them all out to inspect the
rabbits. When it grew too hot in the sun, they came indoors again,
and Barbara took them up to her nursery—a room so full of beautiful
toys that Molly and Maud felt as if suddenly transported to fairyland.
“What do you suppose is going to happen?” Daisy whispered to
Dulcie, on the way up-stairs. “Are we to stay here till somebody
comes to take us home?”
“I don’t know,” Dulcie answered mournfully; “Mrs. Thorne is attending
to everything, and I don’t like to ask her any questions. The thing I’m
most afraid of is that Grandma may come for us herself. It would be
dreadful to have to go all the way home in the train with Grandma.”
At one o’clock Mrs. Thorne called them all down to luncheon, and it
was just as they were finishing that meal that the telegram arrived.
The waitress brought it in on a tray, and handed it to Mrs. Thorne,
who opened it, and read aloud:
“Please send children home by next train. They will be met
at the station.”
There was a moment of dead silence, and then Mrs. Thorne said
quietly:
“The telegram is from your grandmother, in answer to one I sent her
this morning.”
“We thought it was,” said Dulcie, meekly. “How soon does the next
train go?”
Mrs. Thorne left the room to consult a time-table, and Barbara began
to express her entire disapproval of the whole affair.
“I don’t see why you can’t stay,” she protested; “there’s plenty of
room. It would be so nice to have you stay all summer, and we could
have such fun all together. Wouldn’t you like to stay?”
“It would be lovely,” said Dulcie, politely, “but your mother doesn’t
think it would be right. She is afraid Papa wouldn’t like it.”
“Our papa is coming home to-day,” chimed in Molly, “and we haven’t
seen him for more than a year.”
“Papas are pretty nice,” Barbara admitted, “but of course they’re not
like mammas. I don’t think I could possibly leave Mamma, even to go
to the nicest place in the world. Mamma says perhaps you can come
to see us again some day. I’m so glad your name isn’t Delia Smith,
Dulcie; Dulcie Winslow is ever so much prettier, and I think I like
Daisy better than Margaret, too. I suppose your papa would be
disappointed if you were away when he came. Haven’t you any
mamma?”
“No,” said Dulcie, with a sigh; “she died when we were very little. I
am the only one who can remember her.”
Barbara looked interested.
“My first mamma died when I was a little baby,” she said; “I can’t
remember her a bit.”
The four little Winslows nearly dropped their spoons into the ice-
cream, so great was their astonishment at this amazing
announcement.
“Your—your what?” gasped Dulcie.
“My first mamma,” repeated Barbara, calmly. “I’ve got her picture on
my bureau, and I always kiss her good-night. Mamma says she
loved me very much, but I’m sure she loves me just as much herself,
because she says I’m the preciousest thing in the world.”
At that moment Mrs. Thorne returned, with a time-table in her hand.
“The next down train leaves here in half an hour,” she said; “I’m
afraid we shall have to hurry a little. I have sent word to James to
harness the ponies, and will drive you to the station myself.”
“Mrs. Thorne,” said Dulcie, regarding her hostess with big,
astonished eyes, “I hope it isn’t a rude question, but I’ve got to ask.
Are you—are you Barbara’s stepmother?”
Mrs. Thorne laughed merrily.
“So you have found out,” she said. “Yes, I am, but that doesn’t make
any difference in our love for each other, does it, Barbara darling?”
And she stooped to kiss the little girl, who responded by flinging both
arms round her neck.
“No, indeed it doesn’t,” she cried, heartily. “I wouldn’t change you for
all the mammas in the world.”
“And we thought all stepmothers were wicked and cruel,” said
Dulcie, slowly. “O dear! I’m afraid we’ve been dreadfully silly, and I
guess we’d better go home just as soon as we possibly can.”
CHAPTER XVIII
A HOME-COMING
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.
ebookfinal.com