How to assign a PHP variable that contains a mixed of PHP and html elements?

Posted by Rick on Stack Overflow See other posts from Stack Overflow or by Rick
Published on 2011-01-02T02:20:01Z Indexed on 2011/01/02 2:53 UTC
Read the original article Hit count: 203

Filed under:
|

I have a PHP page that contains html and tags and PHP codes and I am using AJAX to manipulate some data and now I need to spit out the response but I am not sure if it is possible to put the mixed content into a string variable to pass through...

Is this possible? For example I need to:

$response = "<p>some text--<?php echo $something; ?>";

Thanks...

To clear things up, I am not trying to send raw PHP code to clientside as that would be silly and won't be evaluated as it is a server side script. I am just looking for a fast way to put everything into a variable without manually re-doing the whole page stripping out the php open and close tags and echos...etc

© Stack Overflow or respective owner

Related posts about php

Related posts about variables