Foreword
Its hard to believe that nearly 20 years ago I picked up my first PHP book. I had an interest in programming, extending beyond Netscape Composer and static HTML. I knew PHP would enable me to create dynamic, smarter websitesand to store and fetch data to create interactive web applications.
What I didnt know was the journey that unlocking these new capabilities with PHP would take me on, or how PHP would evolve 20 years later to become the programming language powering roughly 80% of the web, and backed by one of the nicest, friendliest, and most engaging communities.
A journey of a thousand miles begins with a single step. By selecting Programming PHP by Peter MacIntyre and Kevin Tatroe, you have taken that first step not only into PHP and its basics, but also into the future of website and web application development. With the available tools and a firm understanding of the PHP programming language, the only limitation will be your imagination and your willingness to continue to grow and immerse yourself in the community. The journey is yours, the possibilities endless, and the future for you to define.
As you get ready to begin this journey, I would like to share a couple tidbits of advice. First, take each chapter and put it into practice, try different things, and dont be afraid of breaking something or failing. While Programming PHP will establish a strong foundation, its up to you to explore the language and find new and creative ways to pull together all of these components.
My second piece of advice: be an active part of the PHP community. Take advantage of online communities, user groups, and PHP conferences as you are able. As you try new things, share them with the community for their feedback and advice.
Not only are you sure to find a community of supporta group of some of the nicest people, who want you to succeed and are more than happy to take their time to help you through your journeybut youll also establish a baseline of continuous learning, helping you grasp the core skills of PHP more quickly and keeping you up to date on new programming theories, technologies, tools, and changes. Not to mention, youll encounter an onslaught of terrible puns (including from yours truly).
With that, I would like to be among the first to welcome you and to wish you the very best on your journeya journey that couldnt start off better than with this book!
Michael Stowe, author, speaker, and technologist
San Francisco, California, Winter 2020
Preface
Now more than ever, the web is a major vehicle for corporate and personal communications. Websites carry satellite images of Earth in its entirety; search for life in outer space; house personal photo albums, business shopping carts, and product lists; and so much more! Many of those websites are driven by PHP, an open source scripting language primarily designed for generating HTML content.
Since its inception in 1994, PHP has swept the web and continues its phenomenal growth today. The millions of websites powered by PHP are testament to its popularity and ease of use. Everyday people can learn PHP and build powerful dynamic websites with it.
The core PHP language (version 7+) features powerful string- and array-handling facilities, as well as greatly improved support for object-oriented programming. With the use of standard and optional extension modules, a PHP application can interact with a database such as MySQL or Oracle, draw graphs, create PDF files, and parse XML files. You can run PHP on Windows, which lets you control other Windows applications (such as Word and Excel with COM) or interact with databases using ODBC.
This book is a guide to the PHP language. When you finish it (we wont tell you how it ends!), you will know how the PHP language works, how to use the many powerful extensions that come standard with PHP, and how to design and build your own PHP web applications.
Audience
PHP is a melting pot of cultures. Web designers appreciate its accessibility and convenience, while programmers appreciate its flexibility, power, diversity, and speed. Both cultures need a clear and accurate reference to the language. If you are a (web) programmer, then this book is for you. We show the big picture of the PHP language, and then discuss the details without wasting your time. The many examples clarify the textual explanations; the practical programming advice and many style tips will help you become not just a PHP programmer, but a