Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

php notes

The document provides an extensive introduction to server-side programming and PHP, covering its definition, importance, and various technologies. It details PHP's syntax, data types, arrays, superglobals, and regular expressions, along with advantages and disadvantages of using PHP. Additionally, it discusses setting up a local development environment and the basics of PHP form handling.

Uploaded by

sainiavinash1111
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

php notes

The document provides an extensive introduction to server-side programming and PHP, covering its definition, importance, and various technologies. It details PHP's syntax, data types, arrays, superglobals, and regular expressions, along with advantages and disadvantages of using PHP. Additionally, it discusses setting up a local development environment and the basics of PHP form handling.

Uploaded by

sainiavinash1111
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

PHP

Unit 1: Introduction to Server-Side Programming and PHP (08 Hours)

1. Introduction to Server-Side Programming

 Definition: Server-side programming involves executing scripts on a web server to


generate dynamic web content, as opposed to client-side programming, which runs in the
user's browser.
 Importance:
o Dynamic Content Generation: Allows websites to deliver personalized and
updated content based on user interactions and data from databases.
o Enhanced Functionality: Server-side languages can handle complex operations
such as database queries, authentication, and business logic.
 Server-Side Technologies:
o Various languages can be used for server-side programming, including:
 PHP (Hypertext Preprocessor): A widely-used open-source language
particularly suited for web development.
 ASP.NET: A framework developed by Microsoft for building dynamic
web applications.
 Ruby on Rails: A web application framework written in Ruby.
 Python (Django, Flask): Frameworks that facilitate the development of
web applications using Python.
 Java (Spring, Java EE): Java-based frameworks for enterprise-level
applications.
 Servers (XAMPP, WAMP, MAMP):
o XAMPP: Cross-platform server solution stack package that includes Apache
HTTP Server, MariaDB, and interpreters for scripts written in PHP and Perl. It is
easy to install and ideal for development.
o WAMP: A Windows-based stack that includes Apache, MySQL, and PHP. It
allows developers to create web applications on Windows.
o MAMP: A similar stack for macOS, providing Apache, MySQL, and PHP.
Useful for macOS developers.
 Static vs. Dynamic Websites:
o Static Websites: Serve fixed content, typically HTML pages, without server-side
processing. Changes require manual updates to the files.
o Dynamic Websites: Generate content dynamically based on user requests, often
involving databases and server-side scripts. Examples include social media sites
and e-commerce platforms.
 Setting Up the Environment:
o Installing a local server stack (e.g., XAMPP, WAMP, or MAMP) to develop and
test PHP applications locally before deploying them on a live server.
o Configuration steps typically include:
1. Downloading the server stack installer.
2. Running the installer and following setup instructions.
3. Starting services (Apache, MySQL) through the control panel.
4. Placing PHP files in the server's document root (e.g., htdocs for
XAMPP).
 Localhost:
o Refers to the local server running on your own machine. Accessed through the
URL http://localhost or http://127.0.0.1.
o Ideal for development, testing, and debugging web applications without needing
an internet connection.

2. Introduction to PHP

 What is PHP?
o PHP: A server-side scripting language designed primarily for web development
but also used as a general-purpose programming language.
o Originally created by Rasmus Lerdorf in 1993 and evolved over time into a
powerful language.
 History of PHP:
o PHP/FI (Personal Home Page/Forms Interpreter): The original version created in
1995.
o PHP 3: Released in 1997, marked a significant upgrade and adoption in web
development.
o PHP 4: Introduced in 2000, included improved performance and support for web
applications.
o PHP 5: Released in 2004, added object-oriented programming features and
improved MySQL integration.
o PHP 7: Launched in 2015, significantly improved performance and introduced
new features like scalar type declarations and return type declarations.
o PHP 8: The latest major release, which includes Just-In-Time compilation, union
types, attributes, and improvements in error handling.
 Advantages of PHP:
o Open Source: Free to use and widely supported by a large community of
developers.
o Cross-Platform: Runs on various operating systems (Windows, Linux, macOS).
o Database Support: Seamless integration with popular databases like MySQL,
PostgreSQL, and SQLite.
o Ease of Learning: Simple syntax and extensive documentation make it accessible
to beginners.
o Robust Community: A large community contributes to a wealth of libraries,
frameworks (e.g., Laravel, Symfony), and resources.
 Disadvantages of PHP:
o Security Issues: Historically criticized for security vulnerabilities; requires
developers to follow best practices.
o Inconsistent Function Naming: Some function names can be non-intuitive or
inconsistent, leading to confusion.
o Performance: While improvements have been made, PHP may not be as
performant as some compiled languages for certain tasks.
 PHP vs. Other Server-Side Technologies:
o Ease of Use: PHP is often easier to set up and get started with compared to
frameworks like ASP.NET or Java.
o Community Support: PHP has extensive community support and resources,
making it easier to find solutions to problems.
o Performance: PHP may lag behind more modern languages/frameworks in
performance, but its speed and efficiency are sufficient for most web applications.
o Flexibility: PHP allows both procedural and object-oriented programming styles,
making it versatile for developers.

Unit II: PHP Syntax and Fundamentals (08 Hours)

1. PHP Syntax

 Basic Syntax:
o PHP code is embedded in HTML using the PHP tags <?php and ?>. Anything
outside of these tags is treated as HTML.
o Example:

<?php
echo "Hello, World!";
?>

 Comments: Comments in PHP are used for documentation and to make the code more
readable. PHP supports both single-line and multi-line comments:
o Single-line comments:

// This is a single-line comment

o Multi-line comments:

/* This is a
multi-line comment */

 Variables:
o Variables in PHP start with the $ symbol followed by the variable name. They are
case-sensitive.
o Variable names must start with a letter or an underscore, followed by any
combination of letters, numbers, or underscores.
o Example:
$name = "John";
$age = 30;

 Output:
o PHP provides two primary ways to output data: echo and print.
o Echo: A language construct used to output one or more strings.

echo "Hello, World!";

o Print: Similar to echo, but it always returns 1, allowing it to be used in


expressions.

print "Hello, World!";

2. Data Types

 Overview: PHP is a loosely typed language, meaning you do not need to declare a
variable's data type.
 Types of Data:
o String: A sequence of characters enclosed in quotes.

$greeting = "Hello, World!";

o Integer: A non-decimal number.

$age = 25;

o Float (Double): A number with a decimal point.

$price = 19.99;

o Boolean: Represents two possible values: true or false.

$is_active = true;

o Array: A collection of values stored in a single variable.

$colors = array("red", "green", "blue");

o Object: An instance of a class, representing a collection of data and methods.


o NULL: A special type representing a variable with no value.

$value = NULL;

3. Strings and String Operations

 String Manipulation:
o Concatenation: Joining two strings using the . operator.
$first_name = "John";
$last_name = "Doe";
$full_name = $first_name . " " . $last_name; // John Doe

o String Functions: PHP provides various built-in functions for string


manipulation:
 strlen($string): Returns the length of a string.
 strtoupper($string): Converts a string to uppercase.
 strtolower($string): Converts a string to lowercase.
 substr($string, $start, $length): Returns a part of a string.

4. Constants

 Definition: Constants are similar to variables, but their values cannot be changed once
defined.
 Defining Constants: Use the define() function to create a constant.

define("SITE_NAME", "MyWebsite");

 Accessing Constants: Access constants without the $ sign.

echo SITE_NAME; // Outputs: MyWebsite

5. Operators

 Types of Operators:
o Arithmetic Operators: Used for performing basic mathematical operations.
 + (addition), - (subtraction), * (multiplication), / (division), % (modulus).
o Assignment Operators: Used to assign values to variables.
 = (assignment), +=, -=, *=, /=, %= for compound assignment.
o Comparison Operators: Used to compare values.
 == (equal), === (identical), != (not equal), !== (not identical), <, >, <=, >=.
o Logical Operators: Used to combine conditional statements.
 && (and), || (or), ! (not).

6. Control Structures

 Conditional Statements:
o If-Else Statement:

if ($age >= 18) {


echo "Adult";
} else {
echo "Minor";
}

o Switch Statement: A multi-way branch statement.


switch ($day) {
case "Monday":
echo "Start of the week";
break;
case "Friday":
echo "End of the week";
break;
default:
echo "Midweek";
}

 Loops:
o While Loop: Executes as long as a condition is true.

while ($count < 5) {


echo $count;
$count++;
}

o Do-While Loop: Executes at least once and then repeats while a condition is true.

do {
echo $count;
$count++;
} while ($count < 5);

o For Loop: Used when the number of iterations is known.

for ($i = 0; $i < 5; $i++) {


echo $i;
}

o Foreach Loop: Specifically for iterating over arrays.

foreach ($colors as $color) {


echo $color;
}

7. Functions

 Definition: A function is a block of code that can be reused and executed when called.
 Creating a Function:

function greet($name) {
return "Hello, " . $name;
}
echo greet("John"); // Outputs: Hello, John

 Built-in Functions: PHP has many built-in functions, such as:


o date(): Returns the current date and time.
o array(): Creates an array.
Unit 3: PHP Array and Superglobals (08 Hours)

1. PHP Arrays

 Introduction to Arrays:
o Definition: An array is a special variable in PHP that can hold multiple values in
a single variable. Arrays are useful for storing a collection of data, such as lists of
items, settings, or records.
o Types of Arrays: PHP supports three main types of arrays:
 Indexed Arrays: Arrays with numeric indices, where each element is
accessed using its index number.
 Associative Arrays: Arrays where each element is identified by a unique
key (string), allowing for easier access to elements based on names rather
than numbers.
 Multidimensional Arrays: Arrays that contain one or more arrays within
them. This structure is useful for representing more complex data, such as
tables.
 Types of Arrays:
o Indexed Arrays:
 Defined using numeric indices. Example:

$fruits = array("Apple", "Banana", "Cherry");


// or using short array syntax
$fruits = ["Apple", "Banana", "Cherry"];

 Accessing elements:

echo $fruits[0]; // Output: Apple

o Associative Arrays:
 Defined using key-value pairs. Example:

$ages = array("Alice" => 25, "Bob" => 30, "Charlie" => 35);
// or using short array syntax
$ages = ["Alice" => 25, "Bob" => 30, "Charlie" => 35];

 Accessing elements:

echo $ages["Bob"]; // Output: 30

o Multidimensional Arrays:
 Arrays containing other arrays. Example:

$students = array(
array("John", 20, "Computer Science"),
array("Jane", 22, "Mathematics"),
array("Mike", 21, "Physics")
);
 Accessing elements:

echo $students[0][1]; // Output: 20 (John's age)

 Sorting Arrays:
o PHP provides several functions to sort arrays:
 sort(): Sorts indexed arrays in ascending order.

sort($fruits); // Sorts $fruits array

 asort(): Sorts associative arrays based on value, maintaining key


associations.

asort($ages); // Sorts $ages array by value

 ksort(): Sorts associative arrays based on key.

ksort($ages); // Sorts $ages array by key

 usort(): Sorts an array with a user-defined comparison function.

usort($students, function($a, $b) {


return $a[1] - $b[1]; // Sort by age
});

2. PHP Superglobals

 Introduction to Superglobals:
o Superglobals are built-in variables in PHP that are always accessible, regardless
of scope. They are used to access information about variables, forms, session data,
server environment, and more. This makes them useful for various programming
scenarios.
 Common Superglobals:
o $GLOBALS:
 An associative array containing all global variables. Useful for accessing
global variables from any function or method.

$x = 10;
function test() {
echo $GLOBALS['x']; // Output: 10
}
test();

o $_SERVER:
 An associative array containing information about headers, paths, and
script locations. Useful for obtaining server-related data.
echo $_SERVER['HTTP_USER_AGENT']; // Outputs the user's
browser information

o $_REQUEST:
 An associative array containing data from both $_GET and $_POST
requests, as well as $_COOKIE data. Used to collect data submitted via
forms.

$name = $_REQUEST['name']; // Accesses data submitted from a


form with the name field

o $_GET:
 An associative array used to collect data sent in the URL query string. It is
typically used for form submissions with method="get".

// URL: example.com/page.php?name=John&age=25
$name = $_GET['name']; // Output: John

o $_POST:
 An associative array used to collect data sent through HTTP POST
method. It is used for forms that require data submission without exposing
it in the URL.

// In a form submission
$name = $_POST['name']; // Output: Data submitted via POST

o $_FILES:
 An associative array used to handle file uploads. Contains information
about files uploaded via forms.

// In a form with enctype="multipart/form-data"


$fileName = $_FILES['file']['name']; // Access the name of
the uploaded file

o $_SESSION:
 An associative array used to store session variables. Data stored in this
array is available across multiple pages during the user's session.

session_start(); // Start a session


$_SESSION['username'] = 'JohnDoe'; // Store a session
variable

o $_COOKIE:
 An associative array used to access cookie values. Cookies are small
pieces of data stored on the client-side.

$user = $_COOKIE['username']; // Access the username stored


in a cookie
3. Regular Expressions in PHP:

 Introduction:
o Regular expressions (regex) are sequences of characters that form search patterns.
They are used for string matching and manipulation.
 Common Functions:
o preg_match(): Checks if a pattern matches a string.

$pattern = "/abc/";
$string = "abcdef";
if (preg_match($pattern, $string)) {
echo "Match found!";
}

o preg_replace(): Performs a search and replace using regex.

$string = "Hello, World!";


$newString = preg_replace("/World/", "PHP", $string);
echo $newString; // Output: Hello, PHP!

o preg_split(): Splits a string by a regular expression pattern.

$string = "one,two,three";
$array = preg_split("/,/", $string);
// $array contains ["one", "two", "three"]

Unit 4: PHP Forms and Advanced Concepts (08 Hours)

1. PHP Form Handling

 Form Handling Basics:


o PHP is commonly used to process data submitted through HTML forms. It allows
for collecting user input, validating it, and performing actions based on that data.
o Forms in HTML can be created using the <form> tag, which contains various
input fields such as text, checkboxes, radio buttons, etc.
 Creating an HTML Form:
o A simple form may look like this:

html
<form action="process.php" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="submit" value="Submit">
</form>
o The action attribute specifies the PHP file that will process the data, while the
method attribute defines how data is sent (GET or POST).
 Handling Form Data in PHP:
o PHP retrieves form data using the $_GET or $_POST superglobals, depending on
the method used.
o Example of processing form data in process.php:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
echo "Name: " . $name . "<br>";
echo "Email: " . $email;
}
?>

o The htmlspecialchars() function is used to prevent XSS (Cross-Site Scripting)


by escaping special characters.
 Form Validation:
o Validation ensures that the data submitted meets certain criteria before being
processed.
o Common validation checks include:
 Required fields
 Valid email format
 Input length checks
 Custom error messages can be provided to guide users.
 Creating a Registration Form:
o A registration form can include fields like name, email, password, and confirm
password. Here’s an example:

html
<form action="register.php" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<label for="confirm_password">Confirm Password:</label>
<input type="password" id="confirm_password"
name="confirm_password" required>
<input type="submit" value="Register">
</form>

o In register.php, validate the inputs and provide feedback.


 Feedback Form:
o A feedback form can allow users to share their opinions or comments about a
service or product. Here’s an example:

html
<form action="feedback.php" method="POST">
<label for="feedback">Feedback:</label>
<textarea id="feedback" name="feedback" rows="4"
required></textarea>
<input type="submit" value="Submit Feedback">
</form>

2. PHP Advanced Concepts

 PHP File Handling:


o PHP can create, read, update, and delete files on the server, which is useful for
storing user data, logs, and other information.
o File Operations:
 Creating a File:

$file = fopen("example.txt", "w"); // Open file for writing


fwrite($file, "Hello, World!"); // Write to file
fclose($file); // Close the file
$file = fopen("example.txt", "r"); // Open file for reading
$content = fread($file, filesize("example.txt")); // Read
the file
fclose($file); // Close the file
echo $content;

 Appending to a File:

$file = fopen("example.txt", "a"); // Open file for


appending
fwrite($file, "Additional content."); // Append to file
fclose($file); // Close the file

 Deleting a File:

unlink("example.txt"); // Delete the file

 Image Upload:
o PHP can handle file uploads, including images, through forms. Here’s a simple
upload form:

html
<form action="upload.php" method="POST" enctype="multipart/form-
data">
<label for="file">Choose an image to upload:</label>
<input type="file" name="file" id="file" accept="image/*"
required>
<input type="submit" value="Upload Image">
</form>

o In upload.php, handle the upload:


if ($_SERVER["REQUEST_METHOD"] == "POST") {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["file"]
["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
echo "File uploaded successfully.";
}

 Session Management:
o Sessions in PHP allow you to store user data across multiple pages. This is crucial
for features like user login and shopping carts.
o Starting a Session:

session_start(); // Start the session


$_SESSION['username'] = 'JohnDoe'; // Store session data

o Accessing Session Variables:

session_start(); // Resume the session


echo $_SESSION['username']; // Access session variable

o Ending a Session:

session_start();
session_unset(); // Remove all session variables
session_destroy(); // Destroy the session

 Cookies:
o Cookies are small files stored on the client’s computer and are used to remember
information about the user.
o Setting a Cookie:

setcookie("user", "JohnDoe", time() + (86400 * 30), "/"); // 86400


= 1 day

o Accessing Cookies:

if(isset($_COOKIE['user'])) {
echo "Welcome back, " . $_COOKIE['user'];
}

o Deleting a Cookie:

setcookie("user", "", time() - 3600, "/"); // Set expiration time


to past

 Exception Handling:
o PHP supports exception handling, allowing developers to manage errors
gracefully.
o Try-Catch Blocks:
try {
// Code that may throw an exception
throw new Exception("An error occurred.");
} catch (Exception $e) {
echo "Caught exception: " . $e->getMessage();
}

 PHP and JSON:


o PHP can encode and decode JSON data, which is commonly used in APIs for data
exchange.
o Encoding PHP Array to JSON:

$data = array("name" => "John", "age" => 30);


echo json_encode($data); // Convert PHP array to JSON

o Decoding JSON to PHP Array:

$json_data = '{"name": "John", "age": 30}';


$data = json_decode($json_data, true); // Convert JSON to PHP
array

Unit 5: PHP OOP, MySQL, APIs, and Frameworks

1. PHP Object-Oriented Programming (OOP)

 Introduction to OOP:
o Object-Oriented Programming (OOP) is a programming paradigm that uses
"objects" to design software. OOP allows for code reusability, modularity, and
better organization of code.
o Key concepts include classes, objects, inheritance, encapsulation, and
polymorphism.
 Classes and Objects:
o Class: A blueprint for creating objects. It defines properties (attributes) and
methods (functions) that the created objects can use.
o Object: An instance of a class. It represents a specific implementation of the
class.
o Syntax Example:

class Car {
public $color;
public $model;

public function __construct($color, $model) {


$this->color = $color;
$this->model = $model;
}

public function getDetails() {


return "Car model: $this->model, Color: $this->color";
}
}

$myCar = new Car("Red", "Toyota");


echo $myCar->getDetails(); // Output: Car model: Toyota, Color:
Red

 Constructor and Destructor:


o Constructor: A special method that is automatically called when an object is
created. It is often used to initialize properties.
o Destructor: A method that is called when an object is destroyed. It can be used to
perform cleanup operations.
o Syntax Example:

class Example {
public function __construct() {
echo "Object created!";
}

public function __destruct() {


echo "Object destroyed!";
}
}

 Abstract Classes and Interfaces:


o Abstract Class: A class that cannot be instantiated and may contain abstract
methods (methods without implementations). Subclasses must implement these
methods.
o Interface: A contract that defines methods that implementing classes must define.
Interfaces cannot contain properties or method implementations.
o Syntax Example:

abstract class Animal {


abstract public function makeSound();
}

class Dog extends Animal {


public function makeSound() {
return "Bark!";
}
}

 Namespaces:
o Namespaces are a way to group related classes, functions, and constants to avoid
naming conflicts. They allow better organization and can be autoloaded.
o Syntax Example:

namespace Animals;

class Cat {
public function meow() {
return "Meow!";
}
}

 Iterables:
o In PHP, an iterable is any variable that can be looped over with foreach. This
includes arrays and objects that implement the Traversable interface.

2. PHP and MySQL

 Introduction to MySQL:
o MySQL is an open-source relational database management system. It uses
Structured Query Language (SQL) for database interactions and is commonly
used with PHP to manage data.
 Connecting to a Database:
o Use the mysqli or PDO (PHP Data Objects) extensions to connect to a MySQL
database.
o Syntax Example (Using mysqli):

$conn = mysqli_connect("localhost", "username", "password",


"database");

if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

 Performing CRUD Operations:


o Create: Use INSERT to add data to the database.
o Read: Use SELECT to retrieve data.
o Update: Use UPDATE to modify existing data.
o Delete: Use DELETE to remove data.
o Syntax Example:

// Create
$sql = "INSERT INTO users (name, email) VALUES ('John Doe',
'john@example.com')";
mysqli_query($conn, $sql);

// Read
$result = mysqli_query($conn, "SELECT * FROM users");
while ($row = mysqli_fetch_assoc($result)) {
echo $row['name'];
}

// Update
$sql = "UPDATE users SET email='john.doe@example.com' WHERE
name='John Doe'";
mysqli_query($conn, $sql);
// Delete
$sql = "DELETE FROM users WHERE name='John Doe'";
mysqli_query($conn, $sql);

 Prepared Statements:
o Prepared statements are a way to execute SQL queries safely, helping to prevent
SQL injection attacks.
o Syntax Example:

$stmt = $conn->prepare("INSERT INTO users (name, email) VALUES (?,


?)");
$stmt->bind_param("ss", $name, $email);
$name = "Jane Doe";
$email = "jane@example.com";
$stmt->execute();

3. APIs (Application Programming Interfaces)

 Introduction to APIs:
o APIs allow different software applications to communicate with each other. They
define a set of rules for how requests and responses are structured.
 Creating an API with PHP:
o You can create RESTful APIs in PHP that can respond to HTTP requests (GET,
POST, PUT, DELETE) and return data in formats like JSON or XML.
o Syntax Example:

header('Content-Type: application/json');
$response = array("message" => "Hello, World!");
echo json_encode($response);

 Using APIs:
o To use external APIs, you can use PHP’s curl functions to send requests and
handle responses.
o Syntax Example:

$url = "https://api.example.com/data";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);

4. PHP Frameworks

 Introduction to PHP Frameworks:


o Frameworks provide a structured way to build web applications. They offer built-
in functionalities, libraries, and tools to simplify development.
 Popular PHP Frameworks:
o Laravel: Known for its elegant syntax, Laravel includes features like routing,
ORM (Eloquent), and built-in security mechanisms.
o Symfony: A robust framework that focuses on reusable components and follows
the MVC (Model-View-Controller) architecture.
o CodeIgniter: A lightweight framework that is easy to set up and use, ideal for
beginners.
o Zend Framework: A robust framework with a focus on enterprise-level
applications.
 Advantages of Using Frameworks:
o Rapid Development: Pre-built components accelerate the development process.
o Security Features: Frameworks often include security measures against common
vulnerabilities (e.g., SQL injection, XSS).
o Maintainability: Code organization and modular design make it easier to
maintain and scale applications.

5. PHPUnit for Testing

 Introduction to PHPUnit:
o PHPUnit is a popular testing framework for PHP that allows developers to write
unit tests for their code, ensuring functionality and reliability.
 Writing Tests:
o Tests are typically written in separate files and organized in a way that
corresponds to the application structure.
o Syntax Example:

use PHPUnit\Framework\TestCase;

class MyTest extends TestCase {


public function testAddition() {
$this->assertEquals(2 + 2, 4);
}
}

 Running Tests:
o PHPUnit can be executed from the command line to run all tests in a specified
directory.
o Use the command:

Bash----------------

phpunit tests/

You might also like