Ok, this is probably my first post of many as I figure out how to get a page template working using php.
Right now, I am trying to include files, and save their *parsed* output as a variable. I am doing this with ob_start, ob_get_contents, and ob_end_clean. Is there a faster way to get a parsed php file's output into a variable (as a string)?
Secondly, I am including a file, which has a function in it. But then later when I try to call that function in the page, I get a fatal error saying the function doesn't exit. Any ideas?
includes, files
Moderator: General Moderators
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: includes, files
includes/requires really dont allow you to grab that page as a variable. It's just a remote piece of code that isnt run, until it is called.
you could include a file that contains a pre-populated variable, or maybe a function that can be called that will return the output you are looking for.
example:
Secondly, If you are receiving an error, then you either included the remote file AFTER you made a call to it, the include is failing, or there is an error in your code.
you could include a file that contains a pre-populated variable, or maybe a function that can be called that will return the output you are looking for.
example:
Code: Select all
<?php
include_once('includes/php_header.php');
$output = some_function_contained_within_php_header.php();
?>Secondly, If you are receiving an error, then you either included the remote file AFTER you made a call to it, the include is failing, or there is an error in your code.
Re: includes, files
Ok, cool. I just have the include spitting out a pre-declared variable and then commented in that fact (for my own future reference).