What are common challenges faced by beginners in understanding PHP?

Beginners in understanding PHP often struggle with syntax errors, variable scope, and understanding how to properly structure their code. To overcome these challenges, it is important to carefully review PHP documentation, practice writing code regularly, and seek help from online resources and communities.

<?php

// Example of correct syntax and variable scope in PHP

$name = "John";

function greet() {
    global $name;
    echo "Hello, $name!";
}

greet();

?>