What is the issue with using variables as parameters in SimpleXMLElement in PHP?

When using variables as parameters in SimpleXMLElement in PHP, the issue arises because SimpleXMLElement expects string literals as parameters, not variables. To solve this issue, you can concatenate the variable within the string literal when passing it as a parameter to SimpleXMLElement.

// Incorrect way of using variable as parameter in SimpleXMLElement
$element = new SimpleXMLElement($variable);

// Correct way of using variable as parameter in SimpleXMLElement
$element = new SimpleXMLElement("$variable");