bgbs Posted February 19, 2010 Share Posted February 19, 2010 I'm using this php echo code and in the last <li> that is empty right now I'm trying to include a file. echo "<ul>"; echo "<li><a href=\"index.php#$ad\">Trade Floor</a></li>"; echo "<li><a href=\"user.php?v_id=$toid\">My Account</a></li>"; "<li></li>"; echo "</ul>"; This is the code below with the include and some more code below that I'm trying to put into echo. Maybe using echo is not the best way in this case, all help and suggestions appreciated. include 'inc.last_search.php' $toName = "" $toEmail = "" $fromName = "" $fromEmail = "" $emailSubj = "" $emailBody = "" $emailSent = "yes" Quote Link to comment https://forums.phpfreaks.com/topic/192647-how-do-i-echo-include/ Share on other sites More sharing options...
mikesta707 Posted February 19, 2010 Share Posted February 19, 2010 include and echo don't work that way. All include does is more or less take the code from the file you include, and plop it wherever the include line was in your program. If you want to echo stuff from an include file, then echo it directly inside the include file Quote Link to comment https://forums.phpfreaks.com/topic/192647-how-do-i-echo-include/#findComment-1014898 Share on other sites More sharing options...
bgbs Posted February 19, 2010 Author Share Posted February 19, 2010 include and echo don't work that way. All include does is more or less take the code from the file you include, and plop it wherever the include line was in your program. If you want to echo stuff from an include file, then echo it directly inside the include file include and echo don't work that way. All include does is more or less take the code from the file you include, and plop it wherever the include line was in your program. If you want to echo stuff from an include file, then echo it directly inside the include file Ok so help me out, how do I code this correctly? Will this work fine then? echo "<ul>"; echo "<li><a href=\"index.php#$ad\">Trade Floor</a></li>"; echo "<li><a href=\"user.php?v_id=$toid\">My Account</a></li>"; include "inc.last_search.php"; $toName = ""; $toEmail = ""; $fromName = ""; $fromEmail = ""; $emailSubj = ""; $emailBody = ""; $emailSent = "yes"; echo "</ul>"; Quote Link to comment https://forums.phpfreaks.com/topic/192647-how-do-i-echo-include/#findComment-1014905 Share on other sites More sharing options...
meltingpoint Posted February 19, 2010 Share Posted February 19, 2010 Put that piece of code that you want to echo in a separate php script - then do an if statement if( $a == $b) { include("script_with_echo.php"); } else { include("another_script_with_echo.php"); } Obviously the if statement will be made to what ever condition you are wand to set- I just used $a == $b as an example. Does that give you an idea to build upon? Quote Link to comment https://forums.phpfreaks.com/topic/192647-how-do-i-echo-include/#findComment-1014920 Share on other sites More sharing options...
bgbs Posted February 19, 2010 Author Share Posted February 19, 2010 Thanks, that should help me out Quote Link to comment https://forums.phpfreaks.com/topic/192647-how-do-i-echo-include/#findComment-1014933 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.