$html = '<html><body>$DATA</body></html>';
$DATA = "<h1>Hi</h1>";
eval("\$html = \"$html\";");
echo $html;
The above piece of code will resolve the variable of $DATA properly. While
$html = '<html><body>$DATA</body></html>';
$DATA = "<h1>Hi</h1>";
$html = "$html";
echo $html;
This piece of code will not. Why? What is the difference between these two?
Isn't the eval("\$html = \"$html\";"); equal to just $html = "$html"; ?
Why first one works while the other one doesn't?
As in my above examples; $DATA is and must be defined after the $html. That's the case :). In other case I wouldn't even have a question and bother.
But it's... why first one works while second one doesn't. And how to make the second one works? But primarly why it doesn't in fact work.