Advanced_PHP_Full_Notes
Advanced_PHP_Full_Notes
1.1 Classes: A class is a blueprint for creating objects. It defines properties and methods.
1.2 Objects: An object is an instance of a class that has values assigned to its properties.
1.3 Introspection: The ability to analyze an object or class at runtime using functions like get_class().
1.5 Inheritance: Allows a class to inherit properties and methods from another class.
1.7 Encapsulation: Restricting access to certain properties and methods to ensure data security.
<?php
class Car {
public $brand;
function setBrand($name) {
$this->brand = $name;
}
function getBrand() {
return $this->brand;
}
}
2. Web Techniques
2.1 Server Information: PHP provides $_SERVER superglobal to get server details.
2.2 Processing Forms: Data submitted via GET or POST is handled using $_GET and $_POST.
2.3 Sticky Forms: Retain input values after form submission.
2.4 Setting Response Headers: Use header() function to control HTTP responses.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
echo "Hello, " . htmlspecialchars($name);
}
?>
<form method="post">
Name: <input type="text" name="name">
<input type="submit">
</form>
<?php
$xml = simplexml_load_string("<user><name>John</name></user>");
$xml->name = "Alice";
echo $xml->asXML();
?>
4.1 JavaScript for AJAX: Uses XMLHttpRequest or Fetch API to send/receive data asynchronously.
4.2 AJAX Web Application Model: Sends requests without reloading the page.
4.3 AJAX-PHP Framework: PHP handles requests and returns responses.
4.4 Performing AJAX Validation: Validate form inputs dynamically.
4.5 Handling XML Data: AJAX retrieves XML from PHP.
4.6 Connecting Database: AJAX communicates with a MySQL database.
5.1 Definition: Web services allow different applications to communicate over the internet.
5.2 Operational Model: Client sends a request, server processes it, and responds.
5.3 Benefits & Challenges: Platform independence, standardization vs security risks.
5.4 Architecture: Uses SOAP or REST.
5.5 Core Components: SOAP, REST, WSDL, UDDI.
5.6 Standards: XML-RPC, RESTful APIs.
5.7 Communication Models: Synchronous & Asynchronous.
5.8 Steps to Implement: Create API, connect DB, return response.
<?php
header("Content-Type: application/json");
$conn = new mysqli("localhost", "root", "", "testdb");
$result = $conn->query("SELECT * FROM users");
$users = array();
echo json_encode($users);
?>
6.1 Introduction: Joomla and Drupal are CMS for building dynamic websites.
6.2 Features: Joomla is user-friendly, Drupal offers more customization.
6.3 Administration: Manage layout, content, and system settings.
6.4 Working with Joomla: Create pages, install themes, and add extensions.