Skip to content

Commit 78f28fb

Browse files
committed
Add PHP roadmap content
1 parent 412676b commit 78f28fb

File tree

121 files changed

+1589
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1589
-440
lines changed

scripts/roadmap-tree-content.js

Lines changed: 251 additions & 320 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
# $_GET
1+
# $_GET
2+
3+
$_GET is a pre-defined array in PHP, that's used to collect form-data sent through HTTP GET method. It's useful whenever you need to process or interact with data that has been passed in via a URL's query string. For an example if you have a form with a GET method, you can get the values of the form elements through this global $_GET array. Here’s an example:
4+
5+
```php
6+
<form method="get" action="test.php">
7+
Name: <input type="text" name="fname">
8+
<input type="submit">
9+
</form>
10+
```
11+
12+
Using $_GET, you can fetch the 'fname' value from the URL:
13+
14+
```php
15+
echo "Name is: " . $_GET['fname'];
16+
```
17+
18+
Visit the following resources to learn more:
19+
20+
- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.get.php)
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# $_POST
1+
# $_POST
2+
3+
`$_POST` is a superglobal variable in PHP that's used to collect form data submitted via HTTP POST method. Your PHP script can access this data through `$_POST`. Let's say you have a simple HTML form on your webpage. When the user submits this form, the entered data can be fetched using `$_POST`. Here's a brief example:
4+
5+
```
6+
<?php
7+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
8+
$name = $_POST["name"];
9+
}
10+
?>
11+
```
12+
13+
In this code, $_POST["name"] fetches the value entered in the 'name' field of the form. Always be cautious when using `$_POST` as it may contain user input which is a common source of vulnerabilities. Always validate and sanitize data from `$_POST` before using it.
14+
15+
Visit the following resources to learn more:
16+
17+
- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.post.php)
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# $_REQUEST
1+
# $_REQUEST
2+
3+
$_REQUEST is a PHP superglobal variable that contains the contents of both $_GET, $_POST, and $_COOKIE. It is used to collect data sent via both the GET and POST methods, as well as cookies. $_REQUEST is useful if you do not care about the method used to send data, but its usage is generally discouraged as it could lead to security vulnerabilities. Here's a simple example:
4+
5+
```
6+
$name = $_REQUEST['name'];
7+
```
8+
9+
This statement will store the value of the 'name' field sent through either a GET or POST method. Always remember to sanitize user input to avoid security problems.
10+
11+
Visit the following resources to learn more:
12+
13+
- [@official@PHP Documentation](https://www.php.net/manual/en/reserved.variables.request.php)
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# $_SERVER
1+
# $_SERVER
2+
3+
The `$_SERVER` is a superglobal in PHP, holding information about headers, paths, and script locations. $_SERVER is an associative array containing server variables created by the web server. This can include specific environmental configurations, the server signature, your PHP script's paths and details, client data, and the active request/response sequence. Among its many uses, `$_SERVER['REMOTE_ADDR']` can help get the visitor's IP while `$_SERVER['HTTP_USER_AGENT']` offers information about their browser. Don't forget to sanitize the content before use to prevent security exploits.
4+
5+
Here's an easy code sample that prints the client's IP:
6+
7+
```php
8+
echo 'Your IP is: ' . $_SERVER['REMOTE_ADDR'];
9+
```
10+
11+
Visit the following resources to learn more:
12+
13+
- [@official@PHP Documentation](https://www.php.net/reserved.variables.server)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Abstract classes
1+
# Abstract classes
2+
3+
Abstract classes in PHP are those which cannot be instantiated on their own. They are simply blueprints for other classes, providing a predefined structure. By declaring a class as abstract, you can define methods without having to implement them. Subsequent classes, when inheriting from an abstract class, must implement these undefined methods.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation](https://www.php.net/manual/en/language.oop5.abstract.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Access Specifiers
1+
# Access Specifiers
2+
3+
Access specifiers, also known as access modifiers, in PHP are keywords used in the class context which define the visibility and accessibility of properties, methods and constants. PHP supports three types of access specifiers: public, private, and protected. 'Public' specified properties or methods can be accessed from anywhere, 'private' ones can only be accessed within the class that defines them, while 'protected' ones can be accessed within the class itself and by inherited and parent classes. Here's an illustrative example:
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation](https://www.php.net/manual/en/language.oop5.visibility.php)
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# Anonymous Functions
1+
# Anonymous Functions
2+
3+
Anonymous functions in PHP, also known as closures, are functions that do not have a specified name. They are most frequently used as a value for callback parameters, but can be used in many other ways. When creating an anonymous function, you can also inherit variables from the parent scope. Here's a basic usage example:
4+
5+
```php
6+
$greet = function($name)
7+
{
8+
printf("Hello %s\r\n", $name);
9+
};
10+
11+
$greet('World');
12+
$greet('PHP');
13+
```
14+
15+
In this example, we're creating an anonymous function and assigning it to the variable `$greet`. We then call this anonymous function using $greet with 'World' and 'PHP' as arguments.
16+
17+
Visit the following resources to learn more:
18+
19+
- [@official@PHP Documentation - Anonymous Functions](https://www.php.net/manual/en/functions.anonymous.php)
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# Apache
1+
# Apache
2+
3+
Apache is a popular web server that can efficiently host PHP applications. Apache integrates well with PHP, using its `mod_php` module, providing a stable and consistent environment for your PHP scripts to run. This compatibility creates a seamless user experience, as PHP pages are served as if they're part of the website and not just files being executed on the server.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentations - Apache](https://www.php.net/manual/en/install.unix.apache2.php)
8+
- [@official@Apache Website](https://httpd.apache.org/)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Arrays
1+
# Arrays
2+
3+
Arrays in PHP are fundamental data structures that store multiple elements in a particular key-value pair collection. PHP offers extensive support for arrays, making them convenient for storing sets of data or complex collections.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation - Arrays](https://www.php.net/manual/en/language.types.array.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Arrow Functions
1+
# Arrow Functions
2+
3+
Arrow functions provide a more concise syntax to create anonymous functions. The feature enthusiastically borrowed from modern Javascript significantly improves PHP's functional programming credibility. The primary difference between regular PHP closures and PHP Arrow functions is the automatic capturing of variables from the parent scope.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation - Arrow Functions](https://www.php.net/manual/en/functions.arrow.php)
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# Associative Arrays
1+
# Associative Arrays
2+
3+
Associative arrays in PHP are a type of array that uses named keys instead of numeric ones. This provides a more human-readable way to store data where each value can be accessed by its corresponding string key. An example of an associative array could be storing names as keys and their corresponding ages as values. Here's a brief example:
4+
5+
```php
6+
$ages = array(
7+
"Peter" => 35,
8+
"John" => 42,
9+
"Mary" => 27
10+
);
11+
```
12+
13+
In this case, to find out John's age, you would simply use `echo $ages['John']` where 'John' is the key. Associative arrays are also easy to loop through using the `foreach` construct.
14+
15+
Visit the following resources to learn more:
16+
17+
- [@official@PHP Documentation - Associative Arrays](https://www.php.net/manual/en/language.types.array.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Auth Mechanisms
1+
# Auth Mechanisms
2+
3+
When you are developing PHP application, security should always be a top priority and authentication mechanism forms it's very core. It ensures proper establishing of user identities before they can access your system's resources. PHP provides several methods to implement authentication like session-based, token-based, HTTP authentication, and more.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation - Auth Mechanisms](https://www.php.net/manual/en/features.http-auth.php)
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# Autoloading
1+
# Autoloading
2+
3+
Autoloading is a convenient feature in PHP that allows for automated loading of classes or files when they are needed. For example, if you have a class that is not yet included or required in the script, and you're instantiating that class, PHP would automatically include that class file for you, given that it complies with the standard PHP autoloading conventions. This feature cuts down the need to manually include or require files and makes your code cleaner and more efficient to manage. Here's a simple example:
4+
5+
```php
6+
spl_autoload_register(function ($class_name) {
7+
include $class_name . '.php';
8+
});
9+
10+
$obj = new MyClass();
11+
```
12+
13+
In this example, PHP will automatically load the MyClass.php file when the MyClass is instantiated.
14+
15+
Visit the following resources to learn more:
16+
17+
- [@official@PHP Documentation - Autloading](https://www.php.net/manual/en/language.oop5.autoload.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Basic PHP Syntax
1+
# Basic PHP Syntax
2+
3+
PHP syntax is generally considered similar to C-style syntax, where code blocks are defined with curly braces, variables start with a dollar sign ($), and statements end with a semicolon (;), making it relatively easy to learn for programmers familiar with C-like languages; PHP scripts are embedded within HTML using opening tags "<?php" and closing tags "?>" to mark where PHP code should be executed within a web page.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation - Basic Syntax](https://www.php.net/manual/en/langref.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Caching Strategies
1+
# Caching Strategies
2+
3+
Caching Strategies are integral to Performance Optimization in PHP. Caching minimizes server load and enhances application speed by temporarily storing results of expensive operations, so that they can be reused in subsequent requests. Some caching techniques used in PHP include opcode caching, object caching, database query caching or full-page caching. For example, OPcache is an opcode caching system that improves PHP performance by storing precompiled script bytecode in memory, negating the need for PHP to load and parse scripts on every request.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@Official Documentation - Opcache](https://www.php.net/manual/en/book.opcache.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Callback Functions
1+
# Callback Functions
2+
3+
A callback function will use that function on whatever data is returned by a particular method.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@Official Documentation - Callback functions](https://www.php.net/manual/en/language.types.callable.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Casting Data Types
1+
# Casting Data Types
2+
3+
PHP, as a loose typing language, allows us to change the type of a variable or to transform an instance of one data type into another. This operation is known as Casting. When to use casting, however, depends on the situation - it is recommendable when you want explicit control over the data type for an operation. The syntax involves putting the intended type in parentheses before the variable. For example, if you wanted to convert a string to an integer, you'd use: `$myVar = "123"; $intVar = (int) $myVar;`. Here, `$intVar` would be an integer representation of `$myVar`. Remember, the original variable type remains unchanged.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@Official Documentation - Type Casting](https://www.php.net/manual/en/language.types.type-juggling.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Classes and Objects
1+
# Classes and Objects
2+
3+
PHP supports object-oriented programming, offering a multi-paradigm way of coding through classes and objects. A class is like a blueprint for creating objects that encapsulate all faculties, properties and methods. An object, on the other hand, is an instance of a class where you can interact with the class's methods and change its properties. PHP lets you define a class using the keyword 'class', set properties and methods within it, and then create an object of that class using 'new'.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@PHP Documentation - Classes](https://www.php.net/manual/en/language.oop5.php)
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# Composer
1+
# Composer
2+
3+
Composer is a fundamental tool in modern PHP development. It simplifies the management of project dependencies, allowing you to declare what you need and automatically installing those resources in your project. For example, if your PHP project requires a certain library, Composer will fetch the appropriate version and make sure it's available for your project. Here's an example of how to add a dependency using Composer:
4+
5+
```shell
6+
composer require vendor/package
7+
```
8+
9+
This command adds the `vendor/package` dependency to your project. The same goes for removing dependencies, updating them, and more.
10+
11+
Visit the following resources to learn more:
12+
13+
- [@official@Composer Official Website](https://getcomposer.org/doc/)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Conditionals
1+
# Conditionals
2+
3+
Conditionals in PHP, much like in other programming languages, allow for branching in code, meaning your program can choose to execute specific parts of code based on the state of variables or expressions. The most common conditional statements in PHP are "if", "else", and "elseif".
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@Official Documentation - Control Structures](https://www.php.net/manual/en/language.control-structures.php)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
# Configuration Files
1+
# Configuration Files
2+
3+
Configuration files are critical for PHP applications because they help manage dynamic settings like database connection information, error reporting, and many other PHP settings without hard coding, making your application flexible and secure. PHP uses an "php.ini" file to hold these settings. You can modify settings by accessing and changing values in this file. For example, to adjust the maximum file upload size, you might modify the `upload_max_filesize` directive. However, changes to the `php.ini` file take effect only after the server is restarted.
4+
5+
Visit the following resources to learn more:
6+
7+
- [@official@Official Documentation - PHP Config](https://www.php.net/manual/en/ini.list.php)
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# Configuration Tuning
1+
# Configuration Tuning
2+
3+
For performance optimization in PHP, configuration tuning is a crucial step. You can manipulate several settings in your php.ini file to enhance your PHP application's performance. For instance, `memory_limit` is a key parameter that specifies the maximum amount of memory a script can consume. Optimizing this setting will prevent the PHP scripts from eating up all server resources. Similarly, adjusting the `max_execution_time` limits the time a script runs. Just ensure careful configuration since restrictive settings could lead to issues. Here's a simple example of how you might modify these parameters:
4+
5+
```php
6+
// Updating memory_limit
7+
ini_set('memory_limit','256M');
8+
9+
// Updating max_execution_time
10+
ini_set('max_execution_time', '300');
11+
```
12+
13+
Visit the following resources to learn more:
14+
15+
- [@official@Official Documentation - PHP.ini](https://www.php.net/manual/en/ini.core.php)
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# Connection Pooling
1+
# Connection Pooling
2+
3+
Connection pooling is a technique used in PHP to manage and maintain multiple open connections with a database. It reduces the time overhead of constantly opening and closing connections, and ensures efficient utilisation of resources. Connection pooling limits the number of connections opened with the database and instead reuses a pool of existing active connections, thereby significantly enhancing the performance of PHP applications. When a PHP script needs to communicate with the database, it borrows a connection from this pool, performs the operations, and then returns it back to the pool. Although PHP doesn't have native support for connection pooling, it can be achieved through third-party tools like 'pgBouncer' when using PostgreSQL or 'mysqlnd_ms' plugin with MySQL. Note, it's recommended to use connection pooling when you've a high-traffic PHP application.
4+
5+
For more information, visit PHP Database Extensions [here](https://www.php.net/manual/en/refs.database.php).
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
# Constants
1+
# Constants
2+
3+
Constants in PHP are fixed values that do not change during the execution of the script. They can be handy for values that need to be reused often like a website's URL, a company's name, or even a hardcoded database connection string. Unlike variables, once a constant is defined, it cannot be undefined or reassigned. Constants are case-sensitive by default but this can be overridden. They are defined using the define() function or the const keyword. For instance, you can create a constant to hold the value of Pi and call it in your script like this:
4+
5+
```php
6+
define("PI", 3.14);
7+
echo PI; // Outputs: 3.14
8+
```
9+
10+
For more information, visit the PHP documentation on constants [here](https://www.php.net/manual/en/language.constants.php).
Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,26 @@
1-
# Constructor / Destructor
1+
# Constructor / Destructor
2+
3+
Constructor and Destructor methods are fundamental components of Object-Oriented Programming (OOP) in PHP. A constructor is a special type of method that automatically runs upon creating an object, often used to set property values or default behaviors. On the other hand, a destructor is a method that is automatically invoked when an object is due to be destroyed, perfect for cleanup activities. Here is a basic example:
4+
5+
```php
6+
class TestClass {
7+
public $value;
8+
9+
// Constructor Method
10+
public function __construct($val) {
11+
$this->value = $val;
12+
}
13+
14+
// Destructor Method
15+
public function __destruct() {
16+
echo "Object is being destroyed.";
17+
}
18+
}
19+
20+
$obj = new TestClass("Hello World");
21+
echo $obj->value;
22+
// Displays: Hello World
23+
// And when the script ends, "Object is being destroyed."
24+
```
25+
26+
Visit [PHP Constructors and Destructors](https://www.php.net/manual/en/language.oop5.decon.php) for a more detailed look at these vital concepts.

0 commit comments

Comments
 (0)