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! Link to comment https://forums.phpfreaks.com/topic/292644-how-to-include-the-results-of-another-php-file/ Share on other sites More sharing options...
Ch0cu3r Posted November 22, 2014 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 Link to comment https://forums.phpfreaks.com/topic/292644-how-to-include-the-results-of-another-php-file/#findComment-1497335 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. Link to comment https://forums.phpfreaks.com/topic/292644-how-to-include-the-results-of-another-php-file/#findComment-1497338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.