PHP 7.4
# Use PHP 7.4 AddHandler application/x-httpd-php74 .php
PHP 8.0
# Use PHP 8.0 AddHandler application/x-httpd-php80 .php
PHP 8.3
# Use PHP 8.3 AddHandler application/x-httpd-php83 .php
PHP 7.4
# Use PHP 7.4 AddHandler application/x-httpd-php74 .php
PHP 8.0
# Use PHP 8.0 AddHandler application/x-httpd-php80 .php
PHP 8.3
# Use PHP 8.3 AddHandler application/x-httpd-php83 .php
Method 1
<Files "example.txt"> Deny from all </Files>
Method 2
RewriteEngine On RewriteCond %{REQUEST_URI} ^/example.txt$ RewriteRule .* /error-page.html [L]
Method 1
Redirect 301 /oldpage.html http://example.com/newpage.html
Method 2
RewriteEngine On RewriteRule ^oldpage.html$ http://example.com/newpage.html [R=301,L]
Method 1
<?php $name = "John"; $string = "Hello, " . $name . "!"; echo $string; ?>
Method 2
<?php $name = "John"; $string = "Hello, $name!"; echo $string; ?>
$array[] = $value
<?php $array = array(); $array[] = "element1"; $array[] = "element2"; $array[] = "element3"; print_r($array); ?>
array_push()
<?php $array = array(); array_push($array, "element1"); array_push($array, "element2"); array_push($array, "element3"); print_r($array); ?>
MySQLi
<?php $servername = "localhost"; $username = "username"; $password = "password"; $database = "database_name"; $conn = new mysqli($servername, $username, $password, $database); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?>
PDO
<?php $servername = "localhost"; $username = "username"; $password = "password"; $database = "database_name"; try { $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
<?php header("Location: https://www.example.com/newpage.php"); exit; ?>