Book Image

Beginning PHP

By : David Carr, Markus Gray
Book Image

Beginning PHP

By: David Carr, Markus Gray

Overview of this book

<p>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. </p><p> </p><p></p>
Table of Contents (12 chapters)
Beginning PHP
Contributors
Preface
Free Chapter
1
Getting Started with PHP
2
Arrays and Loops
Index

Chapter 3. Functions and Classes

In the previous chapter, we saw how to declare and define an array and covered multiple types of arrays such as the indexed array, associative arrays, and so on. We also saw the various operations that can be performed on an array.

In this chapter, we will identify how to define and call functions. We will also learn how to create classes, and how to use the classes and functions together.

Functions are blocks of code that are packaged into reusable code. A function is a piece of code that returns a value by doing some processing, taking one or more outputs.

A class is a blueprint for an object. Classes form the structure of data and the actions that utilize the information to create objects.

By the end of this chapter, you will be able to:

  • Define and call functions

  • Define classes and create instances of the class using the new keyword

  • Implement and call public and static class functions