What are some common pitfalls for beginners when trying to create a PHP project from scratch?

One common pitfall for beginners when creating a PHP project from scratch is not properly organizing the project structure. It's important to separate concerns by creating folders for different components such as controllers, models, views, and libraries. This helps in maintaining a clean and organized codebase.

// Example project structure
- project_root
  - controllers
    - HomeController.php
  - models
    - UserModel.php
  - views
    - home.php
  - libraries
    - Database.php
```

Another pitfall is not using proper error handling techniques. Beginners often overlook error handling, which can lead to unexpected behavior in the application. It's important to implement try-catch blocks for handling exceptions and use functions like `error_reporting` and `ini_set` to display errors during development.

```php
// Example error handling
try {
    // Code that may throw an exception
} catch (Exception $e) {
    echo 'Caught exception: ' . $e->getMessage();
}
```

Lastly, beginners sometimes forget to sanitize user input, leaving the application vulnerable to security threats like SQL injection. It's crucial to always validate and sanitize user input before using it in database queries or outputting it to the browser.

```php
// Example input sanitization
$userInput = $_POST['username'];
$cleanInput = htmlspecialchars($userInput);