<a href="test-get.php?name=Hannes">Test $_GET</a>
 echo 'Hello ' . htmlspecialchars($_GET["name"]) . '!';
Output:

$_POST

<form method="post" action="process.php">
    <input type="text" name="username">
    <input type="text" name="age">
    <button type="submit">Submit</button>
</form>
/* After submission, $_POST contains:
    $_POST['username'] = 'John';
    $_POST['age'] = '25';
*/

$name = $_POST['username'];
$age = $_POST['age'];

echo 'Name: ' . $name . '<br>';
echo 'Age: ' . $age;
process.php의 출력 화면
// Output the filename of the current script
echo $_SERVER['PHP_SELF'];

// Output the IP address of the host server
echo $_SERVER['SERVER_ADDR'];

// Output the name of the host server
echo $_SERVER['SERVER_NAME'];

// Output the full URL of the current page
echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>
$name = $_COOKIE['name'];
setcookie('name', 'value', time() + (3600 * 24 * 365), '/');
// Check if the username cookie is set
if (isset($_COOKIE['username'])) {
    $username = $_COOKIE['username'];
    echo 'Hello, ' . $username . '!';
} else {
    // If the cookie doesn't exist, display a default message
    echo 'Hello, visitor!';
}

// Set the username cookie to expire in 1 hour
setcookie('username', 'John Doe', time() + 3600);
<?php
// index.php

// Access GET parameter
if (isset($_REQUEST['name'])) {
    $name = $_REQUEST['name'];
    echo "Hello, {$name}!";
}

// Access POST parameter
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_REQUEST['email'])) {
        $email = $_REQUEST['email'];
        echo "Thank you for signing up. Registered email: {$email}";
    }
}

// Access cookie value
if (isset($_REQUEST['visited'])) {
    $visited = $_REQUEST['visited'];
    echo "You have visited before. Last visit date: {$visited}";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>$_REQUEST Example</title>
</head>
<body>
    <h1>User Information Input</h1>
    <form method="post" action="index.php">
        <label for="name">Name:</label>
        <input type="text" name="name" id="name">
        <label for="email">Email:</label>
        <input type="email" name="email" id="email">
        <button type="submit">Sign Up</button>
    </form>
</body>
</html>
<form action="upload-file.php" enctype="multipart/form-data" method="post">
	<input type="file" name="userfile">
	<button type="button">Upload File</button>
</form>
// Uploaded file array
$_FILES['userfile'] // The key corresponds to the name attribute of the input element: name='userfile'

// Key properties of the uploaded file array
$_FILES['userfile']['name']     // Original name of the uploaded file
$_FILES['userfile']['type']     // MIME type of the uploaded file
$_FILES['userfile']['size']     // Size of the uploaded file in bytes
$_FILES['userfile']['tmp_name'] // Temporary file path stored on the server
$_FILES['userfile']['error']    // Error code during the upload process
if ($_FILES['userfile']['error'] === UPLOAD_ERR_OK) {
    $tempFilePath = $_FILES['userfile']['tmp_name'];
    $targetFilePath = 'uploads/' . $_FILES['userfile']['name'];
    
    if (move_uploaded_file($tempFilePath, $targetFilePath)) {
        echo 'The file was uploaded successfully.';
    } else {
        echo 'An error occurred during the file upload.';
    }
} else {
    echo 'An error occurred during the file upload.';
}
session_start();

// Increment the session variable that tracks visit count
if (isset($_SESSION['visit_count'])) {
    $_SESSION['visit_count']++;
} else {
    $_SESSION['visit_count'] = 1;
}

// Display the visit count
echo 'Number of visits: ' . $_SESSION['visit_count'];
// Setting environment variables
$_ENV['DATABASE_HOST'] = 'localhost';
$_ENV['DATABASE_USER'] = 'myuser';
$_ENV['DATABASE_PASSWORD'] = 'mypassword';

// Accessing environment variables
$host = $_ENV['DATABASE_HOST'];
$user = $_ENV['DATABASE_USER'];
$password = $_ENV['DATABASE_PASSWORD'];

// Dumping all environment variables
var_dump($_ENV);
$foo = 'bar';
$value = $GLOBALS['foo'];
$GLOBALS['foo'] = 'baz';