What are common pitfalls when declaring strings in PHP, as seen in the provided code snippet?
Common pitfalls when declaring strings in PHP include using single quotes instead of double quotes, which prevents variable interpolation, and forgetting to escape special characters within the string. To solve these issues, always use double quotes for strings that require variable interpolation and escape special characters using a backslash (\).
// Incorrect way of declaring strings
$name = 'John';
$message = 'Hello, $name!';
// Correct way of declaring strings
$name = 'John';
$message = "Hello, $name!";