the_opposite Posted March 26, 2008 Share Posted March 26, 2008 Hi, This is my first post - I hope it does not break any rules! Here goes... I have a file called include.php which contains just 6 numbers. Say for example "123456" I include this file into another php webpage using the standard include command i.e. <frame src="http://www.example_url.com/mailshot/<?=include("includes/include.php")?>" name="mainFrame" id="mainFrame" /> However, the include is displayed as "1234561" - An extra "1" has been added and I can't work out why? I have double checked the include file - it only contains 6 characters (the file size is just 6 bytes). How can I prevent this extra character being appended to the include file? Many thanks for any help Jason Link to comment https://forums.phpfreaks.com/topic/98000-unwanted-extra-character-is-being-appended-to-an-include-file/ Share on other sites More sharing options...
Demonic Posted March 26, 2008 Share Posted March 26, 2008 Its because your echoing the include() which will always return "true" aka "1".. What exactly are you doing, trying to get a link from a page? How about create a variable in that file and then do <?php $link = "blah/blah/bl.txt"; ?> <?php include("include/include.php"); ?> <frame src="http://www.example_url.com/mailshot/<?=$link?>" name="mainFrame" id="mainFrame" /> Link to comment https://forums.phpfreaks.com/topic/98000-unwanted-extra-character-is-being-appended-to-an-include-file/#findComment-501426 Share on other sites More sharing options...
kenrbnsn Posted March 26, 2008 Share Posted March 26, 2008 The "<?=" is shorthand for "<? echo" which you don't want when including a file. The "1" is being returned by the include() function as an indication of success and the "echo" is sending that to the screen. Try: <frame src="http://www.example_url.com/mailshot/<?php include("includes/include.php")?>" name="mainFrame" id="mainFrame" /> Ken Link to comment https://forums.phpfreaks.com/topic/98000-unwanted-extra-character-is-being-appended-to-an-include-file/#findComment-501428 Share on other sites More sharing options...
Demonic Posted March 26, 2008 Share Posted March 26, 2008 and yeah that^ Link to comment https://forums.phpfreaks.com/topic/98000-unwanted-extra-character-is-being-appended-to-an-include-file/#findComment-501431 Share on other sites More sharing options...
the_opposite Posted March 26, 2008 Author Share Posted March 26, 2008 Wow - thanks for your super quick replies. I didnt realise <?= was short for echo (i'm a beginner) I have replaced it with <?php as suggested and it now works perfectly. Thanks again ! Link to comment https://forums.phpfreaks.com/topic/98000-unwanted-extra-character-is-being-appended-to-an-include-file/#findComment-501442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.