Skip to main content

Creating Your First XAMPP PHP Project

A XAMPP project belongs inside the htdocs folder so Apache can serve it and process PHP.

Create the project

Inside your XAMPP htdocs folder, create campready. Use short, meaningful lowercase folder names without spaces.

Create index.php inside it:

<?php
$projectName = "CampReady";
$currentYear = date("Y");
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?= htmlspecialchars($projectName) ?></title>
</head>
<body>
    <h1><?= htmlspecialchars($projectName) ?></h1>
    <p>Local PHP project running in <?= $currentYear ?>.</p>
</body>
</html>

Start Apache and open http://localhost/campready/.

Do not double-click the PHP file. A file:/// address bypasses Apache, so PHP will not run.

What the code demonstrates

  • variables hold the project name and year
  • PHP output is inserted into HTML
  • htmlspecialchars() safely encodes displayed text
  • index.php loads automatically for the folder URL

Suggested structure

campready/
|-- index.php
|-- css/
|   |-- style.css
|-- includes/
|-- uploads/
|-- assets/

Create only the folders your solution needs. Keep reusable PHP files outside writable upload folders.

Troubleshooting

Symptom Check
Page not found Folder spelling and location in htdocs
PHP appears as text Apache is running and URL starts with localhost
Blank page PHP syntax and error log
Old content Save and refresh without cache
Styles missing Relative path and exact filename

Verification checklist

  • The project is inside htdocs.
  • The main file is index.php.
  • It opens through localhost.
  • PHP outputs the current year.
  • Files contain no real personal data or credentials.