How can quoting strings properly help prevent errors like unexpected T_STRING in PHP code?

When working with strings in PHP, it is important to quote them properly to prevent errors like unexpected T_STRING. This error typically occurs when a string is not enclosed in quotes or the quotes are not properly escaped. To avoid this error, always enclose strings in single or double quotes, and make sure to escape any quotes within the string using a backslash (\).

// Incorrect way to define a string
$string = Hello World;

// Correct way to define a string
$string = "Hello World";