localhost/test
http://localhost/test
The localhost/test path is used for test pages, debug scripts, and development testing. Create a test directory to safely experiment without affecting production code.
Create Test Directory
# Windows XAMPP
cd C:\xampp\htdocs
mkdir test
# Linux
cd /var/www/html
sudo mkdir test
sudo chown -R www-data:www-data test
# Mac MAMP
cd /Applications/MAMP/htdocs
mkdir test
Common Test Files
PHP Info Test
Create test/phpinfo.php:
<?php
// Display PHP configuration
phpinfo();
?>
Access: localhost/test/phpinfo.php
Database Connection Test
Create test/dbtest.php:
<?php
// MySQL connection test
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'test';
$conn = mysqli_connect($host, $user, $pass, $db);
if ($conn) {
echo "Database connected successfully!";
echo "
Server: " . mysqli_get_server_info($conn); mysqli_close($conn); } else { echo "Connection failed: " . mysqli_connect_error(); } ?>
Server: " . mysqli_get_server_info($conn); mysqli_close($conn); } else { echo "Connection failed: " . mysqli_connect_error(); } ?>
PDO Connection Test
<?php
try {
$pdo = new PDO(
"mysql:host=localhost;dbname=test",
"root",
""
);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "PDO connection successful!";
// Test query
$stmt = $pdo->query("SELECT VERSION()");
$version = $stmt->fetch();
echo "
MySQL Version: " . $version[0]; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
MySQL Version: " . $version[0]; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
Server Variables Test
Create test/server.php:
<?php
echo "
"; echo "Server Name: " . $_SERVER['SERVER_NAME'] . "
"; echo "Server Port: " . $_SERVER['SERVER_PORT'] . "
"; echo "Document Root: " . $_SERVER['DOCUMENT_ROOT'] . "
"; echo "PHP Version: " . phpversion() . "
"; echo "OS: " . PHP_OS . "
"; echo "
Server Information
"; echo "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . ""; echo "Server Name: " . $_SERVER['SERVER_NAME'] . "
"; echo "Server Port: " . $_SERVER['SERVER_PORT'] . "
"; echo "Document Root: " . $_SERVER['DOCUMENT_ROOT'] . "
"; echo "PHP Version: " . phpversion() . "
"; echo "OS: " . PHP_OS . "
"; echo "
PHP Modules
"; print_r(get_loaded_extensions()); ?>HTML Test Page
Create test/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Page</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
.success { color: green; }
.error { color: red; }
</style>
</head>
<body>
<h1>Test Page Working</h1>
<p class="success">If you see this, your server is running correctly.</p>
<h2>Quick Tests</h2>
<ul>
<li><a href="phpinfo.php">PHP Info</a></li>
<li><a href="dbtest.php">Database Test</a></li>
<li><a href="server.php">Server Info</a></li>
</ul>
</body>
</html>
JavaScript Test
Create test/script.html:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Test</title>
</head>
<body>
<h1>JavaScript Test</h1>
<button onclick="testFunction()">Click to Test</button>
<div id="output">