Beginning PHP - David Carr - E-Book

Beginning PHP E-Book

David Carr

0,0
21,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Learn all the fundamentals of PHP with a book that blends theory with practice to build up the skills you need for modern web development.


Key FeaturesBrush up on basic PHP 7 syntax and work with variables, data types, arrays, and loops Master advanced concepts like building your own frameworks and creating your own applicationsApply your newly learned PHP skills to a variety of real-life business scenariosBook Description


PHP is the preferred server-side scripting language for tech giants such as Facebook, Wikipedia, and Tumblr despite full-stack JavaScript gaining popularity with upcoming developers. This is because PHP performs better when dealing with heavy computations on the back end. In this book, you’ll learn everything you need to get up and running with the latest version of PHP, including package management with tools such as composer, secure database operations, and a whole host of other best practices that will help you stay a step ahead of traditional programmers.


What you will learnUnderstand the fundamentals of PHP and work with classes and inheritanceLearn about database operations and package management with composerTackle common security concerns and pitfalls using authentication and validationBuild effective PHP applications and frameworks for your business needsWho this book is for


If you’re already familiar with another programming language and want to learn about the fundamentals of PHP programming, you’ll find the flow of this book to be an ideal fit. Having a prior understanding of HTML, MySQL, CSS, and JavaScript will be beneficial, but is not mandatory.


David Carr, for the past 10 years, has been developing applications for the web, using mostly PHP. He does this for a living and loves what he does as every day there is something new and exciting to learn. David often attends multiple PHP conferences and local meetups to learn and teach others. He spends a lot of time learning new techniques and actively helping people learn web development through a variety of help groups. He also writes web development tutorials for his website and blog on advancements in web design and development. You can read more about him at his blog "daveismyname". Markus Gray is a full-stack web developer/designer with 11 years of experience, based in Philadelphia. He has diverse and deep interests in most trending technologies. He spends most of his time helping public and private companies and has also worked with the federal government in the department of education. Currently, he is the CEO of Syncware Technologies, Inc. He is extremely passionate about teaching and hopes to spend more and more time helping young developers in the community become proficient in software development.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 184

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Beginning PHP
Why Subscribe?
PacktPub.com
Contributors
About the Author
Packt Is Searching for Authors like You
Preface
What This Book Covers
What You Need for This Book
Hardware
Software
Who This Book Is For
Conventions
Installation and Setup
Installing WAMP on Windows
Installing LAMP in Linux
Installing MAMP for MAC OS
1. Getting Started with PHP
The Basics
Using PHP to Display "Hello World"
Variables and Data Types
Working with Variables
Operators
Comparison Operators
Logical Operators
Mathematical Operators
Combining Variables and Operators
Conditionals
Working with Conditionals
Activity: Building an Employee Salary Calculator
Summary
2. Arrays and Loops
Arrays
Indexed Arrays
Associative Arrays
Working with Arrays
Converting a String into an Array
Merging an Array into a String
Slicing Arrays
Sorting an Array
Multidimensional Arrays
Including an Array of Hobbies in Our Existing Project
Loops
for Loop
Combining Loops and Arrays
while Loops
Working with the while Function
Do-While Loops
Conversion of a while Loop to a do-while Loop
foreach Loops
Activity: Working with the foreach Loop
Summary
3. Functions and Classes
Functions
Creating a Simple Function
Classes
Activity: Calculate the Monthly Pay of an Employee
Summary
4. Data Operations
Inputting and Outputting Data
Building a Form for Our User List
Connect to a Database
MySQL Basics
Create a Database Table
Insert a Record into the Database
Fetch a Single Row from a Database Table
Fetch Multiple Rows from a Database Table
Update a Record in a Database Table
Delete a Record in a Database Table
Creating an employee Table
Adding Users to a Database
Summary
5. Building a PHP Web Application
Concepts of OOP in a Framework Environment
Namespaces
Namespace App, Controllers, and Use Statements
Defining Classes and Objects Using Namespaces
Methods
Access Modifiers
Structure of a Framework
Activity: Adding Contacts to a Directory
Summary
6. Building a PHP Framework
Setting up a Project Development Environment
Error Reporting Using Composer and Whoops
Setting up Composer
Activity: Using Composer to Install Dependencies
Configuration Class, Default Classes, and Routing
Loading a View File
Manipulating the Output
Base Controller, Default States, and Routing
Setting up Base Controller, Default States, and Routing
Activity: Exploring the Results
Working with PDO
Creating a Contact Controller and Viewing the Records
Activity: Creating and Executing the Model
Summary
7. Authentication and User Management
Setting Up Paths and Inclusion of Bootstrap
Setting up the Paths and Creating the Absolute Paths to the Files Directory
Creating Layout Files
Inclusion of Bootstrap
Inclusion of Bootstrap and HTML Markup
Adding Security to the Project
Helpers
Authentication
Dashboard
Login
Password Hashing
Implementing Validation in PHP
Password Recovery
Introduction to a Third-Party Dependency PHP Mailer
Building a Password Reset Mechanism for Our Application
Building CRUD for User Management
CRUD
Building CRUD for User Management
Optional Activity
Summary
8. Building a Contacts Management System
Overview CMS
CRUD, the Contact Application
Inserting CRUD functionality in Our Contacts Application
Activity: Executing our Application
Comments, Joins, and Date Formatting
Creating a View Page and Building the Comments System
Activity: Loading the Application
Summary
Index

Beginning PHP

Beginning PHP

Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Acquisitions Editor: Koushik Sen

Content Development Editor: Murtaza Haamid

Production Coordinator: Samita Warang

First published: July 2018

Production reference: 1300718

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78953-590-7

www.packtpub.com

https://mapt.packtpub.com/

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit https://mapt.packtpub.com/ website.

Why Subscribe?

Spend less time reading and more time coding with practical eBooks and Videos from over 4,000 industry professionalsImprove your learning with Skill Plans built especially for youGet a free eBook or video every monthMapt is fully searchableCopy and paste, print, and bookmark content

PacktPub.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

Contributors

About the Author

David Carr, for the past 12 years, has been developing applications for the web, using mostly PHP. He does this for a living and loves what he does as every day there is something new and exciting to learn.

David often attends PHP conferences and attends local meetups to learn and teach others.

He spends a lot of time learning new techniques and actively helping other people learn web development through a variety of help groups. He also writes web development tutorials for his website and blog about advancements in web design and development. You can read more about him here: https://daveismyname.blog/.

Markus Gray is a full-stack web developer/designer with 11 years' experience, based in Philadelphia.

He has diverse and deep interests in most trending technologies. He spends most of his time helping public and private companies, and has also worked with the federal government in the department of education. Currently, he is the CEO of Syncware Technologies, Inc. He is extremely passionate about teaching, and hopes to spend more and more time helping young developers in the community become proficient at software development.

Packt Is Searching for Authors like You

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Preface

Developing a website is a priority these days in order for your business to have a presence on the internet. Design and development are foundational steps for any website. PHP is commonly used for website and web application development. PHP is a general purpose, server-side scripting language that's designed to make dynamic pages and applications. PHP as a web development option is secure, fast, and reliable, and also offers lots more advantages that make it accessible to a lot of people. We should consider what has made PHP one of the most widely used programming languages in the web industry.

This book gets you up to speed by starting with basic concepts, such as variables, data types, arrays, and loops. It then progresses to more advanced concepts, such as building your own frameworks and creating your app.

The book has been designed for the purpose of reducing the gap between learning and implementation. It provides a lot of real business case scenarios, which will help you to understand the concepts and get started with writing PHP programs as soon as they complete the book.

What This Book Covers

Chapter 1, Getting Started with PHP, covers the fundamentals of using the PHP programming language. In this chapter, you'll learn basic PHP syntax and program structure. You'll also learn how to use variables, data types, operators, and conditionals.

Chapter 2, Arrays and Loops, shows you how to use the flow control structures. We will specifically cover loops and arrays in this chapter.

Chapter 3, Functions and Classes, teaches you to identify how to define and call functions. We will also cover how to create classes, and how to use the classes and functions together.

Chapter 4, Data Operations, teaches you how to handle input from users and printing outcomes back to them, handling errors gracefully, and learning the basics of using the MySQL database.

Chapter 5, Building a PHP Web Application, teaches you to apply OOP concepts in a framework. We will cover error reporting using the Whoops library and will learn how to handle those errors. We will also cover how to manage and structure our application in a framework.

Chapter 6, Building a PHP Framework, teaches you to build an MVC framework from scratch. Starting from an empty directory, we will build an entire working framework as a starting point for more complex applications.

Chapter 7, Authentication and User Management, teaches you the security aspect of the project, that is, authentication. We will be building login forms which interact with the database to verify the identity of the users. We will also cover how to set up a password recovery mechanism in our application.

Chapter 8, Building a Contacts Management System, teaches you to build a contacts CRUD (Create, Read, Update, and Delete) section, which will have a view page to view an individual contact. We will also be building the comments system for our contact application.

What You Need for This Book

Hardware

The minimum hardware requirements are as follows:

Windows 7 64-bitProcessor: Intel Core processorMemory: 1 GB RAMAn internet connection

Software

WAMP server for WindowsLAMP server for LinuxMAMP server for MacBrowser: the latest version of one or more browsers (Internet Explorer 11, or Chrome 54.0.2840 or newer is recommended)A text editor such as Notepad or Notepad++

Who This Book Is For

This book is for anyone interested in learning the fundamentals of PHP programming. For the best experience, you should have basic knowledge of HTML, CSS, JavaScript, and MySQL.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create a new file and name it syntax.php."

Folder names, filenames, file extensions, pathnames, include file names in text are shown as follows: "To remove an element from an array, use the unset function.

A block of code is set as follows:

<?php echo "Hello World"; ?>

Any command-line input or output is written as follows:

php syntax.php

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "So, when we click on the Submit button, the data will be submitted."

Important new programming terms are shown in bold. Conceptual terms are shown in italics.

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Installation and Setup

Before you start this book, we'll install a PHP server, such as WAMP, and a text editor, such as Atom.

Installing WAMP on Windows

Visit http://www.wampserver.com/en/ in your browser.Click on WAMP SERVER 64 bits or WAMP SERVER 32 bits, depending on your system.Next, there will be a popup, which will give you a couple of warnings. Click on download directly.Open the installer after download.Follow the steps in the installer and that's it! Your WAMP server is ready.

Installing LAMP in Linux

Visit https://bitnami.com/stack/lamp/installer in your browser.Under Linux, click on the Download button.Next, there will be a popup, which will give you options for logging in. Just click on No thanks, just take me to the download option.Open the installer after download.Follow the steps in the installer and that's it! Your LAMP server is ready.

Installing MAMP for MAC OS

Visit https://www.mamp.info/en/ in your browser.Under MAMP, click on DOWNLOAD button.In the next page, click on macOS click on Download button.Open the installer after download.Follow the steps in the installer and that's it! Your MAMP server is ready.