toolman Posted November 6, 2013 Share Posted November 6, 2013 Hi there, I am trying to include a file in this line, but it doesn't seem to be working. Any ideas what I have wrong? $content .= '<div class="jobs-right">' include("sidebar.php") '</div>'; Thanks Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/ Share on other sites More sharing options...
Ch0cu3r Posted November 6, 2013 Share Posted November 6, 2013 That is invalid syntax. And I dont think you can concatenate included files. Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457175 Share on other sites More sharing options...
toolman Posted November 6, 2013 Author Share Posted November 6, 2013 I have also tried this. It includes the file, but not inside the <div> $content .='<div class="jobs-right">'; $content .= include("sidebar.php"); $content .='</div>'; Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457176 Share on other sites More sharing options...
cyberRobot Posted November 6, 2013 Share Posted November 6, 2013 Could you show the code for sidebar.php? Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457191 Share on other sites More sharing options...
trq Posted November 6, 2013 Share Posted November 6, 2013 include doesn't return a string unless your included file has a return statement specifying so. Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457197 Share on other sites More sharing options...
toolman Posted November 6, 2013 Author Share Posted November 6, 2013 Hi Sidebar.php just has some simple text in it, something like "test" - there is no PHP in that file. Is there another way I can write it? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457200 Share on other sites More sharing options...
cyberRobot Posted November 6, 2013 Share Posted November 6, 2013 You could change sidebar.php to sidebar.txt and use file_get_contents(): http://us1.php.net/file_get_contents Quote Link to comment https://forums.phpfreaks.com/topic/283648-inlcude-problem/#findComment-1457202 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.