0% found this document useful (0 votes)
48 views51 pages

Beginning PHP and Mysql From Novice To Professional Third Edition W. Jason Gilmore

The document provides information about various eBooks available for download, including 'Beginning PHP and MySQL From Novice to Professional' by W. Jason Gilmore. It highlights the features of the eBook, such as an overview of PHP and MySQL, installation processes, and advanced topics. Additionally, it lists other eBooks on different subjects available on the same website.

Uploaded by

widbyloura7s
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)
48 views51 pages

Beginning PHP and Mysql From Novice To Professional Third Edition W. Jason Gilmore

The document provides information about various eBooks available for download, including 'Beginning PHP and MySQL From Novice to Professional' by W. Jason Gilmore. It highlights the features of the eBook, such as an overview of PHP and MySQL, installation processes, and advanced topics. Additionally, it lists other eBooks on different subjects available on the same website.

Uploaded by

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

Download the Full Version of the Ebook with Added Features ebookname.

com

Beginning PHP and MySQL From Novice to


Professional Third Edition W. Jason Gilmore

https://ebookname.com/product/beginning-php-and-mysql-from-
novice-to-professional-third-edition-w-jason-gilmore/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Beginning Google Web Toolkit From Novice to Professional


Beginning from Novice to Professional 1st Edition Bram
Smeets
https://ebookname.com/product/beginning-google-web-toolkit-from-
novice-to-professional-beginning-from-novice-to-professional-1st-
edition-bram-smeets/
ebookname.com

Beginning Databases with PostgreSQL From Novice to


Professional Second Edition Beginning from Novice to
Professional Volume 0 Richard Stones
https://ebookname.com/product/beginning-databases-with-postgresql-
from-novice-to-professional-second-edition-beginning-from-novice-to-
professional-volume-0-richard-stones/
ebookname.com

Beginning Ubuntu Server Administration From Novice to


Professional Vugt

https://ebookname.com/product/beginning-ubuntu-server-administration-
from-novice-to-professional-vugt/

ebookname.com

The Bhagavad Gita Bibek Debroy

https://ebookname.com/product/the-bhagavad-gita-bibek-debroy/

ebookname.com
Student Engagement in Urban Schools Beyond Neoliberal
Discourses 1st Edition Brenda J. Mcmahon

https://ebookname.com/product/student-engagement-in-urban-schools-
beyond-neoliberal-discourses-1st-edition-brenda-j-mcmahon/

ebookname.com

Free Will in Montaigne Pascal Diderot Rousseau Voltaire


and Sartre First Printing Edition Mary Efrosini Gregory

https://ebookname.com/product/free-will-in-montaigne-pascal-diderot-
rousseau-voltaire-and-sartre-first-printing-edition-mary-efrosini-
gregory/
ebookname.com

5 Steps to a 5 on the Advanced Placement Examinations


English Language 1st Edition Barbara Murphy

https://ebookname.com/product/5-steps-to-a-5-on-the-advanced-
placement-examinations-english-language-1st-edition-barbara-murphy/

ebookname.com

Disease in Babylonia Cuneiform Monographs 1st Edition


Irving L. Finkel And Markham J. Geller

https://ebookname.com/product/disease-in-babylonia-cuneiform-
monographs-1st-edition-irving-l-finkel-and-markham-j-geller/

ebookname.com

The Crisis of Islamic Civilization 1St Edition Edition Ali


A. Allawi

https://ebookname.com/product/the-crisis-of-islamic-civilization-1st-
edition-edition-ali-a-allawi/

ebookname.com
Propositional Content 1st Edition Peter Hanks

https://ebookname.com/product/propositional-content-1st-edition-peter-
hanks/

ebookname.com
 CYAN  YELLOW
 MAGENTA BLACK
 PANTONE 123 C

Books for professionals by professionals ® The EXPERT’s VOIce ® in Web Development


Companion eBook Available

Beginning PHP and MySQL: Introduces


Introduces
Beginning PHP 5
From Novice to Professional, Third Edition
Beginning and
PHP 6!

PHP and MySQL


Dear Reader,

PHP and
PHP and MySQL have long ranked among the world’s most popular technologies
for building powerful Web sites, and with little wonder. Both offer developers
an amazing array of features, yet have managed to remain very approachable
even to the most novice of developers. In the latest edition of this bestselling
Coauthor of book, you’ll learn all about PHP and MySQL, setting you along the path toward
Beginning PHP and creating the Web site you’ve long dreamed about.
PostgreSQL 8: From I begin with a vast overview of PHP’s capabilities, starting with a survey of the
Novice to Professional installation and configuration process on both the Windows and Linux platforms.

MySQL
Beginning PHP and Oracle: Next, I devote several chapters to basic PHP concepts, including variables,
From Novice to Professional datatypes, functions, string manipulation, object orientation, and user interaction.
I also explain key concepts such as PEAR, session handling, the Smarty templating
engine, Web services, and PDO. You’ll also find a new chapter devoted to creating
multilingual Web sites, and a new chapter that shows you how to create power-
ful Web sites faster using the popular Zend Framework. I’ve also updated the
material to introduce key new features found in the PHP 6 release.
I then introduce many of MySQL’s key features, beginning by guiding you
through MySQL’s installation and configuration process. Next, you’ll learn
about MySQL’s storage engines and datatypes, administration utilities, security
features, and data import/export facilities. I’ll also introduce you to several
advanced features such as triggers, stored procedures, and views. Along the

From Novice to Professional


way, you’ll gain insight into PHP’s ability to communicate with MySQL, and
learn how to create and execute queries, perform searches, and carry out other
key database tasks from within your Web site.
W. Jason Gilmore

Learn how to build dynamic, database-driven


Companion eBook
THE APRESS ROADMAP Web sites using two of the world’s most popular
PHP Objects, Patterns, and
Practice, Second Edition open source technologies.
Beginning PHP and Pro PHP
MySQL, Third Edition

See last page for details The Definitive Guide to


Practical Web 2.0
Applications with PHP
Pro MySQL
Third Edition
on $10 eBook version MySQL, Third Edition
Beginning Joomla!

Third Edition
SOURCE CODE ONLINE
www.apress.com
Visit the companion site at
http://www.beginningphpandmysql.com/ ISBN-13: 978-1-59059-862-7
ISBN-10: 1-59059-862-8
W. Jason Gilmore
54699

US $46.99
Gilmore
Shelve in
PHP/Web Development

User level:
9 781590 598627
Beginner–Intermediate

this print for content only—size & color not accurate spine = 2.02" 1,080 page count
Gilmore_862-8FRONT.fm Page i Wednesday, February 27, 2008 9:00 AM

Beginning PHP and


MySQL
From Novice to Professional,
Third Edition

■■■

W. Jason Gilmore
Gilmore_862-8FRONT.fm Page ii Wednesday, February 27, 2008 9:00 AM

Beginning PHP and MySQL: From Novice to Professional, Third Edition


Copyright © 2008 by W. Jason Gilmore
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-862-7
ISBN-10 (pbk): 1-59059-862-8
ISBN-13 (electronic): 978-1-4302-0299-8
ISBN-10 (electronic): 1-4302-0299-8
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Jonathan Gennick
Technical Reviewers: Jay Pipes and Matt Wade
Editorial Board: Clay Andres, Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell,
Jonathan Gennick, Kevin Goff, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Frank Pohlmann,
Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Senior Project Manager: Tracy Brown Collins
Copy Editor: Bill McManus
Associate Production Director: Kari Brooks-Copony
Production Editor: Kelly Winquist
Compositor: Susan Glinert
Proofreader: Erin Poe
Indexer: John Collin
Artist: April Milne
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or
visit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600,
Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://
www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our Special
Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author nor Apress shall have any liability to any
person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by
the information contained in this work.
The source code for this book is available to readers at http://www.apress.com. You will need to answer
questions pertaining to this book in order to successfully download the code.
Gilmore_862-8FRONT.fm Page iii Wednesday, February 27, 2008 9:00 AM

This one is dedicated to you, Ruby!


Gilmore_862-8FRONT.fm Page iv Wednesday, February 27, 2008 9:00 AM

Contents at a Glance

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii


About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii

■CHAPTER 1 Introducing PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


■CHAPTER 2 Configuring Your Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
■CHAPTER 3 PHP Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
■CHAPTER 4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
■CHAPTER 5 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
■CHAPTER 6 Object-Oriented PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
■CHAPTER 7 Advanced OOP Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
■CHAPTER 8 Error and Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
■CHAPTER 9 Strings and Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
■CHAPTER 10 Working with the File and Operating System . . . . . . . . . . . . . . . . . 277
■CHAPTER 11 PEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
■CHAPTER 12 Date and Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
■CHAPTER 13 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
■CHAPTER 14 Authenticating Your Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
■CHAPTER 15 Handling File Uploads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
■CHAPTER 16 Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
■CHAPTER 17 PHP and LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
■CHAPTER 18 Session Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
■CHAPTER 19 Templating with Smarty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
■CHAPTER 20 Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
■CHAPTER 21 Secure PHP Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539

iv
Gilmore_862-8FRONT.fm Page v Wednesday, February 27, 2008 9:00 AM

■CHAPTER 22 SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567


■CHAPTER 23 Building Web Sites for the World . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
■CHAPTER 24 MVC and the Zend Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
■CHAPTER 25 Introducing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
■CHAPTER 26 Installing and Configuring MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
■CHAPTER 27 The Many MySQL Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
■CHAPTER 28 MySQL Storage Engines and Datatypes . . . . . . . . . . . . . . . . . . . . . . 693
■CHAPTER 29 Securing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
■CHAPTER 30 Using PHP with MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767
■CHAPTER 31 Introducing PDO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
■CHAPTER 32 Stored Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819
■CHAPTER 33 MySQL Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
■CHAPTER 34 MySQL Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863
■CHAPTER 35 Practical Database Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
■CHAPTER 36 Indexes and Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
■CHAPTER 37 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
■CHAPTER 38 Importing and Exporting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957

v
Gilmore_862-8FRONT.fm Page vi Wednesday, February 27, 2008 9:00 AM
Gilmore_862-8FRONT.fm Page vii Wednesday, February 27, 2008 9:00 AM

Contents

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii


About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii

■CHAPTER 1 Introducing PHP ...........................................1

History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
PHP 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
PHP 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
PHP 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
General Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Practicality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Possibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Price . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

■CHAPTER 2 Configuring Your Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Installation Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Downloading Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Downloading PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Obtaining the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Installing Apache and PHP on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Installing Apache and PHP on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Installing IIS and PHP on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Installing IIS and PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Configuring FastCGI to Manage PHP Processes . . . . . . . . . . . . . . . . 22
Testing Your Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Configuring PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Configuring PHP at Build Time on Linux . . . . . . . . . . . . . . . . . . . . . . . 25
Customizing the Windows Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

vii
Gilmore_862-8FRONT.fm Page viii Wednesday, February 27, 2008 9:00 AM

viii ■C O N T E N T S

Run-Time Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Managing PHP’s Configuration Directives . . . . . . . . . . . . . . . . . . . . . 27
PHP’s Configuration Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Choosing a Code Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Adobe Dreamweaver CS3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Notepad++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
PDT (PHP Development Tools). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Zend Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Choosing a Web Hosting Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Seven Questions for Any Prospective Hosting Provider . . . . . . . . . . 51
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

■CHAPTER 3 PHP Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Embedding PHP Code in Your Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . 56


Default Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Short-Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
ASP Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Embedding Multiple Code Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Commenting Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Single-Line C++ Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Shell Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Multiple-Line C Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Outputting Data to the Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
The print() Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
The printf() Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
The sprintf() Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
PHP’s Supported Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Scalar Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Compound Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Converting Between Datatypes Using Type Casting . . . . . . . . . . . . . 69
Adapting Datatypes with Type Juggling . . . . . . . . . . . . . . . . . . . . . . . 70
Type-Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Type Identifier Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Variable Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Variable Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
PHP’s Superglobal Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Variable Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Gilmore_862-8FRONT.fm Page ix Wednesday, February 27, 2008 9:00 AM

■C O N T E N T S ix

Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
String Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Double Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Single Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Heredoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Looping Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
File-Inclusion Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

■CHAPTER 4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Invoking a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113


Creating a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Passing Arguments by Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Passing Arguments by Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Default Argument Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Returning Values from a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Recursive Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Function Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

■CHAPTER 5 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

What Is an Array? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128


Creating an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Creating Arrays with array() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Extracting Arrays with list() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Populating Arrays with a Predefined Value Range . . . . . . . . . . . . . 132
Testing for an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Adding and Removing Array Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Adding a Value to the Front of an Array . . . . . . . . . . . . . . . . . . . . . . 135
Adding a Value onto the End of an Array . . . . . . . . . . . . . . . . . . . . . 135
Removing a Value from the Front of an Array . . . . . . . . . . . . . . . . . 135
Removing a Value from the End of an Array . . . . . . . . . . . . . . . . . . 136
Gilmore_862-8FRONT.fm Page x Wednesday, February 27, 2008 9:00 AM

x ■C O N T E N T S

Locating Array Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136


Searching an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Retrieving Array Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Retrieving Array Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Traversing Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Retrieving the Current Array Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Retrieving the Current Array Value . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Retrieving the Current Array Key and Value . . . . . . . . . . . . . . . . . . . 140
Moving the Array Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Passing Array Values to a Function . . . . . . . . . . . . . . . . . . . . . . . . . 142
Determining Array Size and Uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . 143
Determining the Size of an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Counting Array Value Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Determining Unique Array Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Sorting Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Reversing Array Element Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Flipping Array Keys and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Sorting an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Merging, Slicing, Splicing, and Dissecting Arrays . . . . . . . . . . . . . . . . . . 153
Merging Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Recursively Appending Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Combining Two Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Slicing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Splicing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Calculating an Array Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Calculating Associative Array Intersections . . . . . . . . . . . . . . . . . . . 158
Calculating Array Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Calculating Associative Array Differences . . . . . . . . . . . . . . . . . . . . 159
Other Useful Array Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Returning a Random Set of Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Shuffling Array Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

■CHAPTER 6 Object-Oriented PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

The Benefits of OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Gilmore_862-8FRONT.fm Page xi Wednesday, February 27, 2008 9:00 AM

■C O N T E N T S xi

Key OOP Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166


Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Constructors and Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Static Class Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
The instanceof Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Helper Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Autoloading Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

■CHAPTER 7 Advanced OOP Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

Advanced OOP Features Not Supported by PHP . . . . . . . . . . . . . . . . . . . 194


Object Cloning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Cloning Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
The __clone() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Class Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Inheritance and Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Implementing a Single Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Implementing Multiple Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Abstract Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Introducing Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

■CHAPTER 8 Error and Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Configuration Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214


Error Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Why Exception Handling Is Handy . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
PHP’s Exception-Handling Implementation . . . . . . . . . . . . . . . . . . . 223
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Gilmore_862-8FRONT.fm Page xii Wednesday, February 27, 2008 9:00 AM

xii ■C O N T E N T S

■CHAPTER 9 Strings and Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . 231

Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232


Regular Expression Syntax (POSIX) . . . . . . . . . . . . . . . . . . . . . . . . . . 232
PHP’s Regular Expression Functions (POSIX Extended) . . . . . . . . . 235
Regular Expression Syntax (Perl) . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Other String-Specific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Determining the Length of a String . . . . . . . . . . . . . . . . . . . . . . . . . 249
Comparing Two Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Manipulating String Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Converting Strings to and from HTML . . . . . . . . . . . . . . . . . . . . . . . 254
Alternatives for Regular Expression Functions . . . . . . . . . . . . . . . . . . . . 260
Padding and Stripping a String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Counting Characters and Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Taking Advantage of PEAR: Validate_US . . . . . . . . . . . . . . . . . . . . . . . . . 274
Installing Validate_US . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Using Validate_US . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

■CHAPTER 10 Working with the File and Operating System . . . . . . . . . . . 277


Learning About Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Parsing Directory Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Calculating File, Directory, and Disk Sizes . . . . . . . . . . . . . . . . . . . 281
Determining Access and Modification Times . . . . . . . . . . . . . . . . . 284
Working with Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
The Concept of a Resource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Recognizing Newline Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Recognizing the End-of-File Character . . . . . . . . . . . . . . . . . . . . . . 287
Opening and Closing a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Reading from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Writing a String to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Moving the File Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Reading Directory Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Executing Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
System-Level Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Sanitizing the Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
PHP’s Program Execution Functions . . . . . . . . . . . . . . . . . . . . . . . . . 305
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Gilmore_862-8FRONT.fm Page xiii Wednesday, February 27, 2008 9:00 AM

■C O N T E N T S xiii

■CHAPTER 11 PEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309


Popular PEAR Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Preinstalled Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Installer-Suggested Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
The Power of PEAR: Converting Numeral Formats . . . . . . . . . . . . . . . . . 312
Installing and Updating PEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Installing PEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
PEAR and Hosting Companies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Updating PEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Using the PEAR Package Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Viewing an Installed PEAR Package . . . . . . . . . . . . . . . . . . . . . . . . . 316
Learning More About an Installed PEAR Package . . . . . . . . . . . . . . 317
Installing a PEAR Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Including a Package Within Your Scripts . . . . . . . . . . . . . . . . . . . . . 320
Upgrading Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Uninstalling a Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Downgrading a Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

■CHAPTER 12 Date and Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323


The Unix Timestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
PHP’s Date and Time Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Validating Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Formatting Dates and Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Converting a Timestamp to User-Friendly Values . . . . . . . . . . . . . . 330
Working with Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Date Fu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Displaying the Localized Date and Time . . . . . . . . . . . . . . . . . . . . . 334
Displaying the Web Page’s Most Recent Modification Date . . . . . 338
Determining the Number of Days in the Current Month . . . . . . . . . 339
Determining the Number of Days in Any Given Month . . . . . . . . . . 339
Calculating the Date X Days from the Present Date . . . . . . . . . . . . 340
Taking Advantage of PEAR: Creating a Calendar . . . . . . . . . . . . . . 341
Date and Time Enhancements for PHP 5.1+ Users . . . . . . . . . . . . . . . . 345
Introducing the DateTime Constructor . . . . . . . . . . . . . . . . . . . . . . . 345
Formatting Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Setting the Date After Instantiation . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Setting the Time After Instantiation . . . . . . . . . . . . . . . . . . . . . . . . . 347
Modifying Dates and Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Other documents randomly have
different content
© P & A Photos
STULTZ IN THE COCKPIT OF THE FRIENDSHIP
LOOKING AFT BETWEEN THE GASOLINE TANKS
TWO MUSKETEERS AND—WHAT IS A FEMININE MUSKETEER?

We had expected a pretty routine landing and so I crawled into


the cockpit to take pictures of the reception committee. But as a
matter of fact Friendship’s arrival resembled a rodeo. At once a
dozen small boats began to circle madly about us, the local motto
seeming to be that the early boat catches the plane. It happened
that we had arranged for a mooring of our own to which we wished
to be directed. But each local optimist felt that if he contrived to get
us in tow first he could take the prize to his own mooring and reap
appropriate reward.
Poised in the bows of the launches each maritime cowboy whirled
aloft a coil of rope, attempting to cast it at us. Slim, out on the
pontoon, was doing his best to keep clear and yelled frantically to
ward them off. The noise of the idling motors, augmented by the
racket of the small boats, made hearing difficult. I was convulsed
with laughter. In the cockpit, Bill, I fear, was talking to God about it.
What concerned him most was the risk of ropes becoming entangled
in the propellers, and especially the danger to the visitors
themselves in getting too close to whirling props. At the height of
the excitement enthusiasm completely overcame one would-be
welcomer. He hurled his rope and landed a bull’s eye on Slim, nearly
knocking him into the water. Fortunately I couldn’t hear what Slim
said; at best his enthusiasm for marine affairs was never notable.
The tempo of the maritime merry-go-round was extraordinary.
Truly, I’ve never had a more entertaining half hour.
Finally we contrived to get the thought across that the most we
wanted was to be guided to our own mooring, which we could reach
under our own power. Andy Fulgoni, Paramount camera man, finally
caught the idea and circling around in his own launch contrived to
clear the way for us. In due course, Bill sailed to the mooring and
made fast.
CHAPTER VII
AT TREPASSEY

Log Book:

JUNE 5,—2:45. There is a howling gale outside. The wind


has blown steadily since we arrived and is getting worse
now. Bill says it would be grand if we were in the air, but
we can’t take off against the hill across the bay. We’d have
to turn and turning would mean a slide into the water,
with a heavily loaded plane and side wind.
Slim is aboard now repairing a crack in oil tank with
cement and adhesive tape. It was thought first that the
case would have to be taken off—an impossible job in the
wind.
Everything is being done for a possible departure. The
radio was cutting out yesterday but today Bill says he
found the trouble in a loose connection.
We are lodged in one of the mansions of the town.
It is difficult to raise anything here but “badadoes,”
“tornips” and cabbage. Each family has a garden, a few
sheep and usually a cow.
The stove here is a three-decker, with the oven on top.
Heavy iron kettles and pots are used for cooking. Tea and
coffee only are known. Houses are clean and fences
white-washed.
I could enjoy myself were it not for anxiety about a
take-off today, and the disgusting news of publicity. Every
few minutes a telegraph operator patters over and hands
me a telegram from some one. Some are lovely, and
others disturb me greatly. The latest says B. papers carry
a story I went to recoup fallen fortunes of family.
A photographer is on the way. The train has just pulled
in—it comes twice a week, and the town watches to see
who gets off.
(Continued after tea.) The boys have come. All are
cheerful. One by one the natives drop in to see us.
I was welcomed at the landing as the first woman to
come to Newfoundland. I didn’t get the point. Perhaps the
agent mean flyin’. I dunno. I said I was honored. He said
Nfld. was. La de da.
School had been let out early and I have a vision of
many white pinafores and aprons on the dock. As soon as
we stepped ashore we were given three cheers and the
(aforementioned) government agent rushed up. Also the
telegraph operator with three telegrams for me. We were
led to a dinner of chicken and dandelions and “badadoes.”
Mrs. Deveraux (at the home of whom we are lodged)
was quite overcome, and felt me to be sure I was present
in the flesh.
We may not get off tomorrow as the wind is as violent
as ever; which means the expected storm is coming
nearer.

* * * *
The wind held the key to our problems. For three days it blew
briskly from the northwest. This was ideal for the flight itself, but far
from ideal locally, as it stirred up such sea it was impossible to load
the gasoline with safety. What’s more, Bill feared that the heavy
weight of the load left on board the Friendship might seriously injure
her as she was buffeted about in the rough water.
The necessity of landing at all at Trepassey was a tragedy for us,
the extent of which became apparent during the fortnight of delay
which followed. Had we been able to carry enough gas from Halifax
we certainly would have kept on eastward as the flying conditions on
the day of our arrival appeared ideal. But once in Trepassey we were
trapped.

* * * *
Log Book:
(Next morning.) The wind is changing though still
stormy. The additional gas is being put aboard and Bill,
after looking over the situation, is snoozing. The wind is
veering back and forth, now from S. now from N.? The
old-timers say a S.W. wind is due. We hope so!!!!!
After supper, June 6. Bill has just been flying the kite
and trying out the emergency radio. Andy Fulgoni, Claud
Frazer and I went into the doctor’s and heard his signals
very plainly. He was trying to reach Cape Race. Just now
the gang has gone to W.U., and I haven’t heard whether
they were successful.
We have spent one indolent day. After the excitement
of the morning, when the wind seemed to be shifting
permanently, all of us had a sleep. Bill chopped a little
wood. Slim and I played “rummy.” I read one of the six
books here, “The Story of the Titanic Disaster.” We have
read telegrams and scanned maps and weather reports. I
took a walk with Andy and Claud Frazer.
For supper we had canned rabbit. Bill’s comment when
he first tasted it was: “Here’s something they caught last
year—something that couldn’t get away.”
We had fish today for the first time—canned last year
in Newfoundland. Slim hates fish, and had been told that
was all there was to eat. Also that even eggs would taste
of fish because hens were fed on fish. He has been eating
chocolates by the package and seems to thrive.

* * * *
Slim hails from Texas. Geographically and temperamentally he is
no sailor. Even the word “pontoon” made him stutter a bit, and
neither salt water nor its products held any joy for him.
Consequently he had been plentifully stuffed with stories of what life
meant in a fishing village by the sea. To make matters worse he had
had a severe attack of ptomaine poisoning from eating clams in
Boston just before we started. The only escape led to the little local
store and its limited supply of candy. Before we left we had
completely absorbed its entire stock.

* * * *

“X MARKS THE SPOT”—OUR HOME IN TREPASSEY


MAIN STREET, TREPASSEY

Log Book:
Bill has just come in, with weather reports. He has
wired Byrd for confirmation of plans and advice. If the
wind holds as now (from north) we can get away. The old
codgers talking here, told me the wind calms down about
4 a.m., so I suggested we get out of this trap and into the
next harbor. The change in the wind may make this
unnecessary. The boys have retired in the hope the wind
stays as is, or moves north.
Funny spelling in the paper from St. John’s. “D’oyleys”
meaning little paper mats. The language is peculiar. There
are too many “r’s.” And often an “oi” sound where one
doesn’t belong. “Poilet” for pilot.
I investigated hooked rugs today. Mrs. D. has them all
over the house; some made from cotton washed ashore
twenty years ago from a wreck. By the way, much of the
silver and some furniture is from wrecks which ground on
this “Graveyard of the Atlantic.”

* * * *
The cruelty of country and climate is surely a contrast to the kind
hearts of the people of Newfoundland. They were untiringly good to
us.

* * * *
Log Book:
June 7, 1928.
After an early rise to get the ship ready, the wind
calmed, and we waited for it to freshen and also for
weather reports. After getting favorable ones we thought
about noon we would be able to get off, as the wind
changed and water grew rough.
In vain we tried three times and had to give up. Slim
had cemented a pontoon which had sprung a leak and is
now soldering the cracked oil tank which the cement and
adhesive tape didn’t repair.
Just now Bill is playing on a strange instrument with
Andy. They are trying to learn it from directions given. The
fence is lined with listeners who are starved for music.
The only music here is two “Gramophones”—this
instrument, a “guitar harp”—and a piano. The fence is
lined with men as soon as any music is started. Though
the people crave it, they don’t try to have any. How
different from the expressive South! Here emotions are as
unexpressed as nature is barren.
Friday. Is it possible we have been here so long? I
didn’t get up very early ce matin as I depended upon
being waked. The thing which did get me up was the
strain of “Jingle Bells” played by Wilmer Stultz on the
strange instrument described before. Just now Slim is
asleep.
Bill and Andy and Frazer out in a dory with a sail. Bill
has my leather coat as neither of the boys brought
anything but ordinary coats.
They played at tying knots all the morning, and Slim
and I had “rummy” games. I have been having a terrific
run of luck—winning every game nearly, at a cent a point.
We played until after ten last night—very late hour for us.
The men are simply great under the strain. Our hopes
are high today as the barometer is rising and everything
points to favorable weather soon.
I went out in a launch yesterday and was run on the
rocks. The leak made was so bad that the boat had to be
beached this morning for repairs. The water is shallow
along the shore, and, as I have said before, the rocks are
cruel.
The men from here go fishing next week and will be
gone five weeks. They are preparing for their voyages
now. I should think they’d get out of the habit of working.
I am sure they would if living didn’t have to be scratched
for so hard.
Compared with Tyler St. the children here seem very
quiet. I think they are unusually so anyway. I just heard
two make some noise and it sounded very strange. Of
course, they are shy, too.
* * * *
For two years I have been associated with Denison House,
Boston’s old settlement center on Tyler Street, where the children
are anything but quiet. There they are mostly Chinese and Syrians.
All city children somehow seem noisy. Perhaps that is because of
their cramped surroundings. And especially, of course, the urban
child is boldly independent, while the children of remote
communities have so little contact with the outer world that they are
self-conscious with strangers.

* * * *
Log Book:
June 9, 1928.
The evening of the day is here. The boys and I played
“rummy” all the morning and I lost for a change. At
luncheon we had lamb stew. Apparently no one knows
about cooking lamb except by boiling. I should love to
have a chop. At supper we had fresh salmon. It was
delicious. Slim and I sat and talked over the meal while
Bill went to W.U. The boys had been out fishing in the
afternoon. They started to explore a cave but found the
water too rough. There are two good caves here which
have never been explored. How I’d like to explore them.
There might be buried treasure—in fact, there have been
several attempts to dig up some at the other end of the
bay. I don’t know who the “buriers” are supposed to be.
Mr. Deveraux has just come in and suggested we go
eeling. I have just returned from a walk and the boys from
Fulgoni’s. Eeling is off. The gang is going down on a
gasoline rail car for a ride. They have wired the Supt. for
permission to use it and are off to Biscay Bay. They wear
their flying suits, as the wind is really cold.
Our telegrams decreased today. I had time to wash my
hair. I wish I had manicuring facilities and a bath tub.
June 10.
The indefatigable Bill insisted on going eeling or
trouting or exploring. Slim refused to get up and slept
until five. Bill dragged the other two, and two natives,
with him to the other end of the bay. They constructed an
eel trap before they left but took poles too. At six they
returned with some beautiful speckled trout, nearly all
caught by B. S. He hiked back into the woods to a stream
while the others sat and caught one sea trout from the
boat.
Fog has come in thick and woolly and rain is now
accompanying. The weather reports sound favorable but
there is no chance of our getting out of this fog I fear. Job
had nothing on us. We are just managing to keep from
suicide.
June 11.
The fog has cleared and I think a wind is coming. Bill
has a hunch we move soon. I hope he is right. We have
not yet received G.P.’s report.
10:35 p.m. I have never been so faithful to a diary. No
luck today. We could have got off here but the Atlantic
wasn’t inviting. Reports today say mayhap tomorrow noon
will be propitious.
The gang went to see the old spiked cannon on the hill
at the mouth of the bay. They are overgrown and are at
least 200 yrs. old. They bear G.R. on them. We all came
home and tried to work puzzles the whole evening.
Andy has a passion for stuffing the town gossip here,
so slipped out to tell him the usual string of stories for the
day. This morning he had him [the t.g.] up at five for the
take-off which he promised rain or shine.
Oh, if only we can get away soon. It is hard indeed to
remain sans books, sans contact with one’s interests and
withal on a terrific strain.
The wind is chill tonight and even with a flannel
nightgown I know I shall shiver.

* * * *
The flannel nightgown referred to was borrowed and I began to
feel that even its sturdy fabric would be worn out before we ever got
away from Trepassey—although I didn’t know about the wearing
qualities of flannel gowns, never having had one before. Incidentally
its warmth was supplemented by the down beds upon which we
slept and into which we sank luxuriously.
I have said my outfit consisted of a toothbrush and two
handkerchiefs when we shoved off from Boston. The toothbrush was
holding out, which is more than I can say for some of the rest of my
personal equipment.
After a week of waiting, a telegram came from G. P. P. in New
York.
“Suggest you turn in and have your laundering done.”
To which I dispatched this reply:
‡[THANKS FATHERLY TELEGRAM NO WASHING NECESSARY SOCKS
UNDERWEAR WORN OUT SHIRT LOST TO SLIM AT RUMMY CHEERIO
A E
910PM]
© International Photos
SLIM ON THE JOB
THE INEVITABLE WINTER WOODPILE

It is a long time since I have bought hose at 35c a pair. That was
top-price in Trepassey. A khaki shirt was another purchase. With a
safety pin taking a tuck in the back of the collar, it fitted reasonably
well.
Bill and I wore the same size shirt. An echo of its tailoring came
later when Mrs. Stultz confessed to me that on first seeing Bill’s
Trepassey purchase she had asked him what it was.

* * * *
Log Book:
June 12.
This has been the worst day.
We tried for four hours to get away in a wind we had
been praying for. The most unexpected and disappointing
circumstance ruined the take-off. The receding tide made
the sea so heavy that the spray was thrown so high that it
drowned the outboard motors. As we gathered speed, the
motors would cut and we’d lose the precious pull
necessary.
The ship seemed so loggy that Bill felt there must be
water in the pontoons. So Slim stayed on the job and
opened every hatch to see. He found only about a gallon
and swears he’ll never open another one.
We unloaded every ounce of stuff from the plane—
camera, my coat, bags, cushions, etc.
She would have gone but for the motors. There was
salt water above the prop. hubs.
I received some letters today and Andy brought over
some “day after the take-off” papers in Boston. I couldn’t
read them under the circumstances of this day. We were
all too disappointed to talk. The boys are in bed and I am
going soon. We rise at six.
Wednesday Evening.
The days grow worse. I think each time we have
reached the low, but find we haven’t.
Vainly we tried to rise today with our load.
Today Bill and Slim tried to take her off after she had
been “degassed” by 300 lbs. The left motor cut and they
couldn’t get her off light. While working with it they set
some yokel to watch the tide, but he forgot, and it ran out
leaving them on a sandy ledge. They got the motor
repaired and will have to go out at midnight to float her
down to the buoy. We may try for the Azores tomorrow, if
possible at dawn.
I went to the Catholic School for maps but found
nothing helpful but a huge globe. I promised to write the
sisters if we hit land anywhere. I am going to bed as I
can’t help and none of us are sleeping much any more
and we need all we can get. We are on the ragged edge.
Bill is getting ship reports at midnight tonight and will
make his own weather map from them.

* * * *
The next log book entry emphasizes our isolation. The only
newspapers we’d seen had been a stray batch from Boston,
describing the take-off. By then that seemed in the dark ages. So far
as we knew we were comfortably forgotten by the world. Echoes
only came to us in personal messages, and at that time it was
impossible to realize that any general interest remained.

* * * *
Log Book:
Apparently from the telegrams to me today our
troubles are painted heavily for they all say—“stick to it,”
“we’re for you,” etc. One inventor has written he will
install his invention gratuitously and guarantee we can get
off with maximum load. Our efficiency will be increased
35% etc. It will take only a month to get the apparatus
here, and twelve hours to install. We all wish we had a
dozen with us.
I saw an interesting stunt. There are wells here and all
water has to be carried to the houses. A little girl—a really
little girl—put two buckets of H2O on a stick and then
separated the buckets by a barrel hoop and stepped
inside. Thus she could carry the two without having them
hit her legs.
The evening of the 15th day. We have had a musical
evening again tonight. The old harp was bro’t forth and
Bill and Andy played. It is very funny to see two able-
bodied men picking out “Jingle Bells.” Two are required for
the feat and I am terribly amused. Bill has a good deal of
music in him and knows some Spanish stuff of which I am
very fond.
Today has been happier as a whole. We all appeared
this morning vowing to change clothes and clean up. I
bought a 90c green checked Mother Hubbard, the best in
stock and a pair of tan hose. With borrowed shoes, skirt
and slip, I pitched in and washed everything else. Bill
borrowed trousers, and had his suit cleaned and pressed
and his shirts laundered. He purchased a new tie as the
one he had was fast “going to the devil” and some
Trepassey socks. Slim also is spic and span. All we need
are baths, manicures and haircuts—none of which are
obtainable here.

* * * *
In those last days at Trepassey, one bit of news that did filter in
from the outside world cheered us mightily. That was word of the
successful flight of the Southern Cross from San Francisco across the
Pacific. She was a tri-motor Fokker, engined with Wright Whirlwind
motors, practically identical with the Friendship except that she was
not equipped with pontoons.
They made it; so could we. Their accomplishment was a
challenge.
CHAPTER VIII
ACROSS

Log Book:

SUNDAY—At the present time we have been out an hour.


Land has gone in the haze and we are almost into the fog
bank which hangs always off the coast of Newfoundland.
We have 1500 ft. and both boys are in the cockpit. Me, I
am holding down a pile of flying suits, as we left every
ounce we could spare at Trepassey and the three cushions
were among the things discarded.
We made three tries before we got off and went up
from a heavy sea with one motor so wet it has just come
in full recently. We had to throw out all our canned gas.
We have only 700 gals, with us now.

* * * *
That was the first entry in the log book following the actual take-
off from Trepassey. We left the harbor about 11:15 in the morning,
having waited until then for final weather reports. The villagers had
seen us “start” so often they had lost faith, so there were only a few
on shore to see the Friendship take the air.
I had left a telegram to be sent half an hour after we had gone.
“Violet. Cheerio.
“A. E.”
That was the message. The code word “Violet” meant “We are
just hopping off.” That was our official good-bye to America.
* * * *
Log Book:
A motion picture camera and the boys’ thermos bottle
left. We have only the small thermos filled with coffee for
the boys. I shan’t drink anything probably unless we come
down.

* * * *
By the way, our rations might be considered eccentric. About half
of the five gallons of mineral water put on at Boston remained.
There were three elephantine egg sandwiches. (Trepassey bread is
home-made in round loaves.) Eight or nine oranges survived from
the original supply. A couple of tins of Drake’s oatmeal cookies were
luxury. For emergency ration, we had a few tins of pemmican, a
bottle of Horlick’s Malted Milk tablets, and some Hershey’s chocolate.
And that, I think, completed the larder.

* * * *
This ship takes off better in a fairly smooth sea, it
seems. I have learned a lot and designers of pontoons
have something to learn too.
We are skimming the fluffy top of the fog now, having
wobbled through to 2500 feet. Bill is at the controls until
we get out of it. He thinks we shall pass through alternate
storm areas and clears the whole distance. Wisps of cloud
flit past the windows of the cabin. Sometimes the fog
obscures everything.
We are climbing fast to crawl over now. Almost 3000
ft.!
There is very blue sky above and when last I saw H2O
it was also brilliant.
THE FRIENDSHIP OFF TREPASSEY
B-A-A-A! A FRONT LAWN AT TREPASSEY

As we left Newfoundland we flew about 1000 ft. over


the land. I watch the shapes of the many lakes, large and
small, which cover the terrain. Two are gigantic footprints;
another a buffalo—another a prehistoric animal.

‡[is this a pleseosaurus?]


There were many “things” depicted with lumpy paws
and flat head and the usual accumulation of abnormalities
belonging to the genus Thing. 3300 ft. Over an extensive
cushion of fleecy fog.
Bill has been at radio and writes CEV to me. I grab call
book and find SS. Elmworth is calling.
Soon Cape Race asks how things are going.
We are at 5000 now getting out of fog, but into a
storm. A flurry of snow just passed below. I can see clear
weather to right, but not ahead. Temperature back here
42 degrees. I am not cold, as I got used to cold in
Trepassey.
Speaking of Fog again, I know Dunsany would like to
see the world above the earth. Irish fogs have been
described in detail, and their bilious effect, and their
fairies and their little people. But no one has written of a
bird’s-eye view of one from an imaginative eye.
I may not be cold, but my coat will make me more
comfortable.
4000 ft. More than three tons of us hurtling through
the air. We are in the storm now. 3 tons is shaken
considerably.

* * * *
People are so likely to think of planes as frail craft that I draw
attention to this entry. Friendship weighs 6000 pounds empty, and
on the flight she carried about her own weight again.

* * * *
Log Book:
Bill is nosing her down, all motors wide.
We are bucking a head wind and rain. Heaviest storm I
have ever been in, in the air, and had to go through. The
sea below looks fairly placid, but of course the surface
appears flat from 3000.

* * * *
A surprising element of flying, at first, is the flatness of the earth’s
contours as seen from above—even sizeable hills dwarf. This
tendency gives one a feeling of security and a comfortable belief
that a safe landing can be made almost anywhere.
“The higher the safer” is a good adage. The air itself isn’t
dangerous, as I have said before. The greater the altitude, the larger
the pilot’s choice in picking and being able to reach a landing field in
an emergency.
Don’t ask a pilot to stay close to the ground, unless he is flying
over geographical billiard tables.

* * * *
Log Book:
I see some clear sea ahead and the air is getting
bumpy, as one would expect between areas of cloud and
sun. Slim comes back to say snow is in the air. I know it.
I have just come back from sitting up front. Slim at the
controls with Bill advising him. Bill has homing pigeon
sense of direction.... He tells Slim to keep at 106.
We have been out of snow a long while now and the
sun is shining and the water blue as far as one can see.
There are some clouds ahead—what, I don’t know. They
look high and white.

* * * *
Those clouds ahead continued from there on. Not again on the
flight did we see the ocean. Skippy was right—it was no sea voyage.
* * * *
Log Book:
140 m.p.h. now. Wonderful time. Temp. 52. The heater
from cockpit warms the cabin too.
Bill says radio is cuckoo. He is calling now.
There is so much to write. I wonder whether ol’ diary
will hold out.
I see clouds coming. They lie on the horizon like a long
shore line.
I have just uncurled from lying on Major Woolley’s suit
for half an hour. I came off this morn with such a
headache that I could hardly see. I thought if I put it to
sleep it might get lost in the billows of fog we are flying
over.
There is nothing to see but churned mist, very white in
the afternoon sun. I can’t see an end to it. 3600 ft. temp.
52, 45 degrees outside. I have et a orange, one of the
originals. At T. our infrequent oranges came from Spain,
under-nourished little bloods.

* * * *
Very “original” those oranges, almost historic! They were
purchased in Boston in the dark ages of the Friendship’s take-offs. In
the three unsuccessful efforts during that fortnight of
disappointments, they went out to the ship with us each morning
and came back again to the hotel. But sturdy oranges they proved to
be, and nearly a month later were still in good form when they
finally found a place on our mid-Atlantic menu.
On the trans-Atlantic flight three oranges, appropriately from
California, comprised my full bill-of-fare with the exception of
probably a dozen malted milk tablets. The sandwiches and the
coffee I left to the boys. Somehow I wasn’t hungry and, curiously, at
the end of the trip there still wasn’t any particular desire for food.

* * * *
Log Book:
4:15. Bill has just opened the motor to climb over this
fog. We are 3800 and climbing.
Creatures of fog rear their heads above the
surroundings. And what a wallop we get as we go through
them.
Bill has just picked up XHY British Ship Rexmore, which
gives us bearing. 48 no. 39 west 20:45 GMT. The fog is
growing patchy and great holes of ocean can be seen.
XHY will inform NY of our position.
As I look out of the window I see a true rainbow—I
mean the famous circle. It is of course moving at our
speed and is on our right, sun being to port a trifle. I have
heard of color circles in Hawaii.
The sun is sinking behind a limitless sea of fog and we
have a bright rainbow, a fainter ring and, if I am not
seeing things, a third suggestion on the edge. The middle
is predominately yellow with a round grey shadow in the
center. Is it caused from us or our props?

* * * *
This is not an unknown phenomenon. Subsequently I learned the
rainbows were caused by our propellers.

* * * *
Log Book:
I do believe we are getting out of fog. Marvellous
shapes in white stand out, some trailing shimmering veils.
The clouds look like icebergs in the distance. It seemed
almost impossible to believe that one couldn’t bounce
forever on the packed fog we are leaving. The highest
peaks of the fog mountains, (oh, we didn’t get out) are
tinted pink, with the setting sun. The hollows are grey and
shadowy. Bill just got the time. O. K. sez he. 10:20
London time my watch. Pemmican is being passed or just
has been. What stuff!
The pink vastness reminds me of the Mojave Desert.
Also:

J’ai miré dans ma prunel


Petite minute éblouie
La grande lumière éternele.

(Bill gets position. We are out 1096 miles at 10:30


London time,)—and having done so he is content to die. I
wish I had that poem here.
One of the greatest sights is the sun splashing to
oblivion behind the fog, but showing pink glows through
apertures in the fog. I wish the sun would linger longer.
We shall soon be grey-sheathed.
We are sinking in the fog.
4000 ft.
The light of the exhausts is beginning to show as pink
as the last glow of the sky. Endless foggies. The view is
too vast and lovely for words. I think I am happy—sad
admission of scant intellectual equipment.
I am getting housemaid’s knee kneeling here at the
table gulping beauty.

* * * *
Rollin Kirby in the New York World
© Wide World Photos
FOR NINETEEN HOURS ONLY A SEA OF CLOUDS

I was kneeling beside the chart table, which was in front of the
window on the port side. Through it I looked northward. It was at
this time that I took several photographs.
On the starboard side of the plane was another window. The
table itself, a folding device, was Bill’s chart table on which he made
his calculations. Close by was the radio. Even though one could
stand up in the cabin, the height of the table was such that to see
out of the window one had to lean on the table or kneel beside it.
There was nothing to sit on, as sitting equipment had been
jettisoned to save weight.

* * * *
Log Book:
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!

ebookname.com

You might also like