Gunnard Engebreth and Satej Kumar Sahu

PHP 8 Basics

For Programming and Web Development

Gunnard Engebreth
Madison, WI, USA
Satej Kumar Sahu
Bangalore, India
ISBN 978-1-4842-8081-2e-ISBN 978-1-4842-8082-9
© Gunnard Engebreth, Satej Kumar Sahu 2023
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.

The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.

This book is dedicated to my wife Erica and to my boys Trip and Wyatt.Also, you the reader. Thank you!

Jesus looked at them and said, “With man this is impossible, but with God all things are possible.”

—Matthew 19:26!

Introduction

Developing web pages and applications is still, after many years, one of the most fascinating endeavors for developers. The idea of taking a simple idea and developing it, seeing it coming alive and imagining the experience the user will have is something very magical.

The experience of programming as web developer should, of course, also be easy, user-friendly, and flexible—all characteristics of the programming language this book is all about: PHP version 8.

The first version of PHP was created by Rasmus Lerdorf in 1994 and he mainly used it on his home page to keep track of who was looking at his online resume. In 1995, the first public version was published as the Personal Home Page Tools.

In the beginning, PHP was just a simple programming language with a very easy parser engine that only understood a small number of utilities and macros.

PHP usage grown. In 1996, about 15,000 web sites were developed with PHP; by 1997, it was up to 50,000. In 1999, about 1 million web sites were developed with PHP. At the time of writing, 78 million of web sites have been developed with PHP to give you a perspective of how popular this programming language has become. Why?

Simple. Because after many years it is still easy to use, user-friendly, and clearly organized. This helps would-be programmers easily understand and run PHP commands and functions.

We want to help PHP beginners and would-be developers explore the new features added to this version 8 and see how easy, flexible, and powerful it can be to develop new web sites and applications.

You will find all the basic information about how to install and configure PHP version 8.

All basic PHP concepts like data types, functions, regular expressions, form handling and verification, sessions, cookies, and filters are introduced and demonstrated with many examples.

We also introduce the basic information of object-oriented programming and its classes and objects.

This book also provides some simple examples about how to use PHP version 8 with one of the most powerful and used databases for developers, MySQL. You learn how to develop an entire web application using PHP version 8 and MySQL.

You also learn about PHP frameworks and why they are so important to use. This book focuses on just two of the many PHP frameworks available, Symfony and Laravel, and the development of web applications following the model–view–controller architectural pattern.

Who This Book Is For

The book assumes you have some web development and DB handling knowledge. The book is written mainly for the beginning web developer who wants to learn how to use PHP version 8 and how it can be used with MySQL and PHP frameworks like laravel and Symfony. It also assumes you have some knowledge of programing language frameworks and how and when you should use them with PHP.

Prerequisites

The examples in this book were built with PHP version 8. We also used MySQL for Ubuntu Linux version 22.04 DEB Bundle. As a testing tool, we used the latest Postman API client version available on the Web, but you are free to use any testing tool you feel comfortable with. Finally, we introduced and utilized two different PHP Frameworks named Laravel and Symfony, which will be needed for the examples of this book.

Downloading the Code

The source code for the examples in this book is available at www.github.com/apress/php8-basics.

Acknowledgments

I would like to dedicate this book to my parents for always believing in and having patience with me while I pursued my interest in technology, and gave me the freedom to explore and try different things. Also, thanks to my sister Lipsa for always being beside me whenever I needed her. I would like to thank all my teachers for being with me during my journey, Runish for the foundational mentoring support at the start of my career, Mindfire Solutions for my first career opportunity, and to all with whom I had an opportunity to interact and learn from. Last but not least I would like to thank Mark for the awesome opportunity to write my first book and the wonderful team at Apress for all their support without whom this book would not have been possible.

Table of Contents
About the Authors
Gunnard Engebreth
began coding at the age of 11 through a “Learning BASIC” book given to him by his father. Technology was changing fast, and Gunnard rode the wave from 1200 to 56k baud modems. Logging into BBSs, Prodigy, CompuServe, Delphi, and IRC, he could see the world changing and he wanted to be a part of it. He soon got involved in the ANSI/demo scene, making several application generators for many groups in the 1990s. Visual Basic was his next language of choice, allowing him to develop “tools” for online systems such as AOL. This introduced many aspects of development, security, and user interfaces while they were still in their infancy. Once the World Wide Web arrived via Mindspring in Atlanta, Georgia, Gunnard quickly joined in the race for the Web. Learning HTML, PERL, and Linux (Slackware at the time), he began to build his skill set, which led to a full-time systems administrator position at the age of 20 (2000) at Activegrams/Silverpop. Gunnard has moved around the IT industry from SAN/NAS storage at IBM to custom WordPress sites for marketing companies, but one thing has stayed the same: his passion for learning and problem solving. Gunnard also DJs drum and bass as Section31, plays drums, and bakes bread (www.gunnard.org).
 
Satej Kumar Sahu
works in the role of Senior Software Data Architect at Boeing. He is passionate about technology, people, and nature. He believes that through technology and conscientious decision making, each of us has the power to make this world a better place. In his free time, he can be found reading books, playing basketball, and having fun with friends and family. 
 
About the Contributor
Massimo Nardone
has more than 26 years of experience in security, web/mobile development, and cloud and IT architecture. His true IT passions are security and Android. He has been programming and teaching how to program with Android, Perl, PHP, Java, VB, Python, C/C++, and MySQL for more than 25 years. He holds a Master of Science degree in Computing Science from the University of Salerno, Italy. He has worked as a Chief Information Security Office (CISO), software engineer, chief security architect, security executive, OT/IoT/IIoT Security Leader, and architect for many years.
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset