How can I get the value of a variable written in string?
Answers
-
You can use php function eval()
<?php $string = "beautiful"; $time = "winter"; $str = 'This is a $string $time morning!'; echo $str. "<br>"; eval("\$str = \"$str\";"); echo $str; ?>
This will output
This is a $string $time morning!
This is a beautiful winter morning!0
Howdy, Stranger!
Categories
- 83 All Categories
- 15 VoIP
- 7 SIP
- 11 asterisk
- 41 Programming
- 1 Nodejs
- 4 javascript
- 18 PHP
- 8 Codeigniter
- 12 database
- 1 UI/UX
- 2 Flutter
- 25 OS
- 23 Linux
- 1 Virtualization
- 1 Android
- 1 Windows
- 2 legal