Lee-Bartlett Posted November 4, 2008 Share Posted November 4, 2008 Where am i going wrong? </tr> <tr> <td height="20" colspan="2" bgcolor="#0099FF"><?php $footer = implode("", file("includes/footer.php")); echo $footer; ?></td> </tr> </table> The file is includes then its called footer.php anyone? Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/ Share on other sites More sharing options...
Andy-H Posted November 4, 2008 Share Posted November 4, 2008 implode is a function used on an array data-type. not a file... http://php.net/implode Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682107 Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 well...what is it doing (or not doing) and how does that differ from what you expect? Your code will read all the lines from footer.php and output them. No PHP code will be processed. If you want the PHP code to be processed, try this: </tr> <tr> <td height="20" colspan="2" bgcolor="#0099FF"><?php include("includes/footer.php"); ?></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682111 Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 implode is a function used on an array data-type. not a file... http://php.net/implode file() returns an array... Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682113 Share on other sites More sharing options...
Lee-Bartlett Posted November 4, 2008 Author Share Posted November 4, 2008 Oh sorry, its not showing anything in the bottom table. My uncle sites uses it for code wrapping round templates, he told me to look at smarty templates to, but this is bit of his code he uses. $sql = "select * from member where id='$ID'"; $res = mysql_query($sql); $cnt = mysql_num_rows($res); $data = @MYSQL_FETCH_ARRAY($res); $page1 = implode("", file("../templ/members/header.htt")); $page2 = implode("", file("../templ/footer.htt")); $pagads = implode("", file("../templ/ads.htt")); Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682114 Share on other sites More sharing options...
Andy-H Posted November 4, 2008 Share Posted November 4, 2008 so it does lol Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682115 Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 what is the contents of "includes/footer.php"? Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682117 Share on other sites More sharing options...
Lee-Bartlett Posted November 4, 2008 Author Share Posted November 4, 2008 just text, 2008 copy righted, to test it, nothing else Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682119 Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 then both the code you posted and the code i posted should work. if you do a View Source on the page do you see the text? If so, then you have an HTML/CSS issue Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682122 Share on other sites More sharing options...
Lee-Bartlett Posted November 4, 2008 Author Share Posted November 4, 2008 Yours is an include file though, i no you can use includes here but i was told to use implodes. Somthing to do with code wrapping round templates. Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682125 Share on other sites More sharing options...
Lee-Bartlett Posted November 4, 2008 Author Share Posted November 4, 2008 This is all the php code in my uncles file, he wants me to replicate this, but on a more basic level. session_start(); $UID = $_SESSION['UID']; //$propid = $id; if(!$UID) { $page = implode("", file("../templ/error.htt")); if($rdr1 == 1) $page = ereg_replace('ddd.com', "dd.com", $page); $msg = "Please <a href=\"login.php\">Login Here</a><br><br>"; $msg .= 'Not a member yet? <a href="register.php">Register</a> in 30 seconds and list your property!'; $page = ereg_replace('{MESSAGE}', $msg, $page); echo $page; exit(); } $sql = "select * from member where id='$UID'"; $res = mysql_query($sql); $cnt = mysql_num_rows($res); $data = @MYSQL_FETCH_ARRAY($res); $page1 = implode("", file("../templ/members/header.htt")); $page2 = implode("", file("../templ/footer.htt")); $pagads = implode("", file("../templ/ads.htt")); $title = "Rentals: Edit profile"; $page1 = ereg_replace('{TITLE}', $title, $page1); $ADM = $_SESSION['ADMIN']; if($ADM == "yes") { $page1 = ereg_replace('{ADS}', "<p>", $page1); $page1 = preg_replace("/<!-- ADMIN(.*?)-->/s", "$1", $page1); } else $page1 = ereg_replace('{ADS}', $pagads, $page1); if($rdr1 == 1) $page1 = ereg_replace('ddd.com', "dd.com", $page1); $page1 = preg_replace("/<!-- PROPERTY -->(.*?)<!-- PROPERTY2 -->/s", "", $page1); $page1 = preg_replace("/<!-- 3 -->(.*?)<!-- 3 -->/", "", $page1); echo $page1; Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682131 Share on other sites More sharing options...
wildteen88 Posted November 4, 2008 Share Posted November 4, 2008 i've never seen the use of implode/file as a better way of including a files contents before. Personally I use include/require etc to include PHP code within my pages, anything else I'd use file_get_contents. Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682250 Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 i can understand the use of file/implode for the sole reason the poster described: Oh sorry, its not showing anything in the bottom table. My uncle sites uses it for code wrapping round templates, he told me to look at smarty templates to, but this is bit of his code he uses. that way you can have your templates more readable with new lines, but when they are loaded, the new lines are stripped out. Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682255 Share on other sites More sharing options...
wildteen88 Posted November 4, 2008 Share Posted November 4, 2008 I just don't think its a very efficient way of doing things. Especially if you leave the first parameter of the implode function blank. Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682261 Share on other sites More sharing options...
Lee-Bartlett Posted November 4, 2008 Author Share Posted November 4, 2008 So the code above, the long pieces about 10th post, could be better done by using require or includes? Quote Link to comment https://forums.phpfreaks.com/topic/131352-implode/#findComment-682334 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.