sphinx Posted October 26, 2011 Share Posted October 26, 2011 Hi, This text outputs itself when i use it for a form field in an echo " value=\"<? include(\"djmessage.txt\"); ?>\" Why is this? it normally works outside of an echo. Many thanks Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/ Share on other sites More sharing options...
trq Posted October 26, 2011 Share Posted October 26, 2011 Can you post your code within a bit more context? Your description of the issue doesn't help much. Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282354 Share on other sites More sharing options...
Buddski Posted October 26, 2011 Share Posted October 26, 2011 I have no idea what you are trying to do there.. Can you show the WHOLE snippet of code, not just that half line.. It looks like you are opening php tags inside, what I presume to be, an echo statement. If you are wanting to use that text file as the value of a HTML element use file_get_contents(), but without seeing the rest of the code I cant help with implementing it. Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282357 Share on other sites More sharing options...
sphinx Posted October 26, 2011 Author Share Posted October 26, 2011 <?php $song = file_get_contents('http://site.com/song.php'); if(!empty($song)) { echo " <form action=\"config.php\" method=\"post\"><br /> <input name=\"checkbox\" value=\"Enable music requests\" type=\"submit\" /><br /><br /> <input name=\"checkbox2\" value=\"Disable music requests\" type=\"submit\" /> </form> <form name=\"input\" action=\"process2.php\" method=\"post\"> DJ Message:<br /> <input type=\"text\" size=\"50\" maxlength=\"200\" value=\"<? include(\"djmessage.txt\"); ?>\" name=\"checkbox3\" /> <input type=\"submit\" value=\"Update\" />"; Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282358 Share on other sites More sharing options...
sphinx Posted October 26, 2011 Author Share Posted October 26, 2011 djmessage.txt contains the custom message that displays on site. Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282359 Share on other sites More sharing options...
Buddski Posted October 26, 2011 Share Posted October 26, 2011 echo " <form action=\"config.php\" method=\"post\"><br /> <input name=\"checkbox\" value=\"Enable music requests\" type=\"submit\" /><br /><br /> <input name=\"checkbox2\" value=\"Disable music requests\" type=\"submit\" /> </form> <form name=\"input\" action=\"process2.php\" method=\"post\"> DJ Message:<br /> <input type=\"text\" size=\"50\" maxlength=\"200\" value=\"".file_get_contents("djmessage.txt")."\" name=\"checkbox3\" /> <input type=\"submit\" value=\"Update\" />"; Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282363 Share on other sites More sharing options...
trq Posted October 26, 2011 Share Posted October 26, 2011 Firstly, your already within php tags, so you don't need more. Secondly, include includes the output of the file where it is called. it does not need to (and can't) be echo'd. Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282364 Share on other sites More sharing options...
jcbones Posted October 26, 2011 Share Posted October 26, 2011 Firstly, your already within php tags, so you don't need more. Secondly, include includes the output of the file where it is called. it does not need to (and can't) be echo'd. It can be echo'd, but only if the include is terminated with a return. Source. I've never used it myself, but just know that it is there. Link to comment https://forums.phpfreaks.com/topic/249833-why-does-this-not-display-in-an-echo/#findComment-1282512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.