In PHP, what is the potential issue with concatenating variable names to create new variables?
When concatenating variable names to create new variables in PHP, it can lead to code that is difficult to read and maintain. It can also introduce security vulnerabilities if user input is used in the concatenation process. Instead, it is recommended to use arrays or associative arrays to store related variables in a structured manner.
// Using arrays to store related variables
$person = [
'name' => 'John',
'age' => 30,
'gender' => 'male'
];
echo $person['name']; // Output: John
echo $person['age']; // Output: 30
echo $person['gender']; // Output: male