PHPNOTES
PHPNOTES
Maintain CMS
1
Learning outcome 1: Apply PHP Fundamentals.
PHP is a very popular language for web development, and it is used by many popular
websites and web applications, including Facebook, Wikipedia, and WordPress. It is
also a relatively easy language to learn, making it a good choice for beginners.
2. Interpreter
3. Open source
Open source is a term that describes products, such as software, that are distributed
with the source code so that anyone can inspect, modify, and enhance it. The source
code is the part of software that most computer users don't ever see; it's the code
computer programmers can manipulate to change how a piece of software—a
"program" or "application"—works.
4. Web server
A web server is a computer that runs websites. It's a computer program that distributes
web pages as they are requisitioned. The basic objective of the web server is to store,
process and deliver web pages to the users.
5. Apache
Apache is a free and open-source web server software that allows users to deploy their
websites on the internet or locally.
6. Database
2
A database is an organized collection of structured information, or data, typically
stored electronically in a computer system.
7. DBMS
8. MySQL
In the context of website creation, static and dynamic refers to the ways in which
websites deliver and display content. The key difference between static websites vs
dynamic websites is that static websites have stable content, where every user sees the
exact same thing on each individual page (like a privacy policy), whereas dynamic
websites pull content on-the-fly, allowing its content to change with the user.
3
Indicative content 1.4: Implementation of Object-oriented programming (OOP) in
PHP.
Class: A class in PHP is a blueprint for creating objects. It defines properties (attributes)
and methods (functions) that the objects created from the class will have.
Object: An object is an instance of a class. It is a specific implementation of the class
with actual values.
Example:
<?php
class Dog {
public $name;
public $age;
$this->name = $name;
$this->age = $age;
4
}
?>
Topic 2. Encapsulation
Encapsulation involves wrapping data and methods that operate on the data into a single unit or class
and restricting direct access to some of the object's components.
Example:
<?php
class BankAccount {
private $balance;
$this->balance = $balance;
if ($amount > 0) {
$this->balance += $amount;
$this->balance -= $amount;
5
}
return $this->balance;
$account->deposit(500);
?>
Topic 3. Inheritance
Inheritance allows a class to inherit properties and methods from another class. The new class (child
class) inherits attributes and methods from the existing class (parent class).
Example:
<?php
class Animal {
public $name;
$this->name = $name;
6
}
?>
4. Polymorphism
Polymorphism allows methods to do different things based on the object it is acting upon, even if they
share the same name.
Example:
<?php
class Bird {
7
}
// Output:
?>
5. Abstraction
Abstraction hides the complex implementation details and shows only the essential features of the
object. It can be achieved through abstract classes and interfaces.
Example:
<?php
8
class Rectangle extends Shape {
private $width;
private $height;
$this->width = $width;
$this->height = $height;
private $radius;
$this->radius = $radius;
9
echo $rectangle->area(); // Output: 12
?>
10