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 won’t 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.
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 good PHP programmer.
If you’re a web designer, you will appreciate the clear and useful guides to specific technologies, such as JSON, XML, sessions, PDF generation, and graphics. And you’ll be able to quickly get the information you need from the language chapters, which explain basic programming concepts in simple terms.
This edition has been fully revised to cover the latest features of PHP version 7.4.
This book assumes you have a working knowledge of HTML. If you don’t know HTML, you should gain some experience with simple web pages before you try to tackle PHP. For more information on HTML, we recommend HTML & XHTML: The Definitive Guide by Chuck Musciano and Bill Kennedy (O’Reilly).
We’ve arranged the material in this book so that you can either read it from start to finish or jump around to hit just the topics that interest you. The book is divided into 18 chapters and 1 appendix, as follows:
The following typographical conventions are used in this book:
Constant width
This icon signifies a tip, suggestion, general note, warning, or caution.
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/oreillymedia/title_title.
If you have a technical question or a problem using the code examples, please send email to [email protected].
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Programming PHP, Fourth Edition, by Kevin Tatroe and Peter MacIntyre (O’Reilly). Copyright 2020 Kevin Tatroe and Peter MacIntyre, 978-1-492-05413-9.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected].
Once again, thanks to every individual who ever committed code to PHP, contributed to the vastness that is the PHP ecosystem, or wrote a line of PHP. You all made PHP what it was, is, and will continue to be.
To my parents, who once purchased a small LEGO set for a long and frightening plane trip, beginning an obsession with creativity and organization that continues to relax and inspire me to this day.
Finally, a heaping fourth spoonful of gratitude to Jenn and Hadden for helping inspire and encourage me through each and every day.
I would like to praise the Lord of Hosts who gives me the strength to face each day! He created electricity through which I make my livelihood; thanks and praise to Him for this totally unique and fascinating portion of His creation!
To Kevin, who is once again my main coauthor on this edition, thanks for the effort and once again staying focused on this project to its publication.
To the technical editors who sifted through our code examples and tested them to make sure we were “telling the truth”—Lincoln, Tanja, Jim, and James—thanks!
And finally to all those at O’Reilly who so often go unmentioned—I don’t know all your names, but I know what you have to do to get a project like this finally “out the door.” The editing, graphics work, layout, planning, marketing, and so on all has to be done, and I certainly appreciate all your hard work toward this end.
For more than 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed.
Our unique network of experts and innovators share their knowledge and expertise through books, articles, conferences, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, please visit http://oreilly.com.
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at https://oreil.ly/programming-PHP-4e.
Email [email protected] to comment or ask technical questions about this book.
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia