Lesson I
Week 1: Introduction to PHP
1.1 Overview of PHP: history and current relevance
PHP, initially standing for "Personal Home Page," is a server-side scripting language used for web development. Here's an overview of its history, current relevance, and an example of its usage:
History of PHP:
Creation: PHP was created by Rasmus Lerdorf in 1994 as a set of Common Gateway Interface (CGI) binaries written in C for managing his personal website. It initially consisted of a few Perl scripts for tracking visits to his online resume.
Growth and PHP/FI: PHP/FI (Personal Home Page/Forms Interpreter) was released in 1995, introducing basic functionality like form handling and the ability to interact with databases.
PHP 3 and 4: PHP 3 (1998) and PHP 4 (2000) brought significant improvements, such as a new Zend engine for better performance, extended language features, and increased stability.
PHP 5: Released in 2004, PHP 5 introduced features like enhanced support for OOP (Object-Oriented Programming), SQLite support, and more.
PHP 7: PHP 7, launched in 2015, was a game-changer with considerable performance improvements, reduced memory consumption, and the introduction of scalar type declarations and return type declarations.
Current Relevance:
Wide Adoption: PHP is still widely used and powers a significant portion of the web. It's the foundation for many popular platforms and frameworks like WordPress, Drupal, Laravel, and Symfony.
Web Development: PHP is primarily used for server-side scripting in web development. It's renowned for its ease of use, versatility, and extensive community support.
Versatility: It's not limited to web development; PHP can also be used for command-line scripting, creating desktop applications, and more.
Example Usage of PHP:
Here's a simple example demonstrating PHP's usage in web development:
<!DOCTYPE html>
<html>
<head>
<title>Hello PHP!</title>
</head>
<body>
<h1>Hello, PHP!</h1>
<?php
// PHP code block
$name = "John"; // Define a variable
echo "Welcome, " . $name . "!"; // Output using echo
?>
</body>
</html>
Explanation:
This code is an HTML document containing embedded PHP code.
The PHP code (<?php ?>) is used to define a variable $name and output a personalized welcome message using echo.
When this file is accessed through a web server with PHP installed, the server executes the PHP code and sends the resulting HTML to the browser.
PHP continues to be a vital part of web development due to its simplicity, powerful features, and widespread community support, maintaining its relevance in the rapidly evolving landscape of technology.
Setting up the PHP development environment (XAMPP, WAMP, MAMP)
Writing and executing the first PHP script