glenelkins Posted November 11, 2006 Share Posted November 11, 2006 HiLets say for instance i have a function that generates a block (displayed with a table Title, and Content). Now say some of these blocks need more than static content. I include a file to run within the code and build up the $content variable. I then use another display function to display the content. How would i include that php code and once the values have been decided for $content the included code is then removed. include_once() and include are not doing what i need as they are in a loop, i need to include, then un-include Link to comment https://forums.phpfreaks.com/topic/26926-include/ Share on other sites More sharing options...
AndyB Posted November 11, 2006 Share Posted November 11, 2006 [quote]i need to include, then un-include[/quote][code] - logic onlyif (something) { include('something_else');}[/code] Link to comment https://forums.phpfreaks.com/topic/26926-include/#findComment-123139 Share on other sites More sharing options...
glenelkins Posted November 11, 2006 Author Share Posted November 11, 2006 its already done like that! but you just given me an idea Link to comment https://forums.phpfreaks.com/topic/26926-include/#findComment-123140 Share on other sites More sharing options...
glenelkins Posted November 11, 2006 Author Share Posted November 11, 2006 actually no that wont work. As when the file is included it is still there, due to the fact its being included as a different file each time in a loop. [code] function GenerateBlocks ($position,$template) { $result = $this->DbQuery ("SELECT * FROM blocks WHERE position='$position'") or die (mysql_error()); while ($blocks = mysql_fetch_array($result)) { if ($blocks['active'] == '1') { echo $blocks['title'] . "<br>"; if ($blocks['admin'] == '1' && $_SESSION['level'] == '1' or $blocks['admin'] == '0') { if ($blocks['members'] == '0' xor $blocks['members'] == '1' && $_SESSION['logged'] == 'yes') { if ($blocks['file'] == '1') { require_once (BLOCKS_FOLDER . $blocks['filename']); $content = array($blocks['title'],$content); } else { $content = array($blocks['title'],$blocks['content']); } $tags = array("{title}","{content}"); $block .= $this->GenerateContent($tags,$content,$template,"block.html"); } } } } return $block; }[/code]so basically require_once, read code... take out Link to comment https://forums.phpfreaks.com/topic/26926-include/#findComment-123141 Share on other sites More sharing options...
glenelkins Posted November 11, 2006 Author Share Posted November 11, 2006 - Link to comment https://forums.phpfreaks.com/topic/26926-include/#findComment-123151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.