Perform PHP variables in another variable

There is a variable containing a regular web form:

$petform = "
<form method=\"post\" action=\"$path\" id=\"contactform\">
<div>
<label for=\"name\"><strong>:</strong></label><br/>
<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" />
</div>
.....
<div>           
<input type=\"submit\" value=\"\" name=\"submit\" />
</div>
</form>";

The problem is that it is necessary to somehow insert the following code into the same variable:

require_once('recaptchalib.php');
$publickey = "57tertwrfs67632462ywr445y"; 
echo recaptcha_get_html($publickey);

So that it is performed in the variable that is displayed. Is it real?

echo recaptcha_get_html($publickey);

Answer 1

Theoretically really, practically why?

Is this not enough?

require_once('recaptchalib.php');
$publickey = "57tertwrfs67632462ywr445y"; 
$petform = "
<form method=\"post\" action=\"$path\" id=\"contactform\">
...
".recaptcha_get_html($publickey)."
</form>";

p.s. On the topic, see the “function” Eval () . But in this case, I repeat, try to refrain from it.