Idefix99 Posted November 22, 2014 Share Posted November 22, 2014 Hi, To start I am quite new to PHP, so this will probably be a question from the 'noob' level. I would like to combine two php files. The first php file post a certain message. The second file retrieves something from a database what I want to include in the message. I found a suggestion somewhere to use ob_start(). $post_message = 'message'; I put the standardized text between the quotes. Obiviously the code below doesn't work, but I don't know how to fix this. ob_start(); include 'otherfile.php'; $result = ob_get_clean(); $post_message = 'message + $result'; Does someone know how I can include the result from the second php file into the message? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted November 22, 2014 Solution Share Posted November 22, 2014 Variables are not expanded within single quotes. Use double quotes or concatenate $result. Examples $post_message = "message $result"; // double quotes // OR $post_message = 'message' . $result; // concatenate Quote Link to comment Share on other sites More sharing options...
Idefix99 Posted November 22, 2014 Author Share Posted November 22, 2014 Thank you so much for the quick reply! I tried both methods and they both work perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.