Skip to content

Instantly share code, notes, and snippets.

@dr5hn
Created October 15, 2017 08:17
Show Gist options
  • Save dr5hn/40dec7cd3ccb2c79ce7305024028b6f9 to your computer and use it in GitHub Desktop.
Save dr5hn/40dec7cd3ccb2c79ce7305024028b6f9 to your computer and use it in GitHub Desktop.
How to create dynamic Variable Name or Create variable from variable in PHP
<?php
$a = 'Hello';
$$a = 'World!'; // This interprets $hello = 'world';
echo "$a ${$a}"; //This will Print Hello World {PHP 7.0}
echo "$a $hello"; // This will also produce the same output Hello World
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment