Sign in to follow this  

[web] Including php files?

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have arrived at a wall: I have PHP that strings multiple files together into a $text variable. Within that $text variable I want to include more PHP files. How can I do that? It looks like this (pseudo code): header.php: $text = "start"; index.php include(header.php) $text .= "middle [want to include a php file here]"; include(footer.php) footer.php $text .= "end"; echo $text thanks.

Share this post


Link to post
Share on other sites
So, do you want to execute a file and have its results put into your $text variable, or do you want to have the contents of the file put into your variable without alteration?

If the former, look into the buffering features of PHP (ob_start(), etc.) -- you should be able to start buffering, execute the file via include(), then nab the contents of the buffer as a string; if the latter, try fopen()ing the file and just reading from it explicitly.

PHP manual on output control:
http://us4.php.net/manual/en/ref.outcontrol.php

Share this post


Link to post
Share on other sites
I have another question : I have a datetime in my database (mysql) and was wondering how to correctly enter a datetime into that via php. I just need to know the function as I already know how to connect to the database and add stuff to it. Just don't know how to get the time in php that will work with datetime in mysql...Thanks!

Share this post


Link to post
Share on other sites

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this