RON_ron Posted February 9, 2012 Share Posted February 9, 2012 A <?php echo "names/new_batch/DataSheet.pdf"; ?> B <?php $link = require( dirname( __FILE__ ) . '/../../../../essentials/myData.php' ); echo ($link); ?> when i call B the result is is shown with an extra "1" at the end names/new_batch/DataSheet.pdf1 What am I doing wrong? How can I get the output as "names/new_batch/DataSheet.pdf" Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/ Share on other sites More sharing options...
Proletarian Posted February 9, 2012 Share Posted February 9, 2012 var_dump your $link variable. I'm going to take a wild guess and say somewhere else you are echoing a "1" and it just appears that it's tagged on the end and not actually appending a "1" to the path. Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/#findComment-1316023 Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2012 Share Posted February 9, 2012 You're assigning the result of require to the variable. require is returning an integer 1 when it succeeds. Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/#findComment-1316028 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2012 Share Posted February 9, 2012 require statements insert the content of the required file in place of the require statement. They don't return the content of the file (edit: unless you are using a URL.) The only time (edit: when you are using a file system path) a value other than a true/1 (success) or false (failure) is returned by a require statement is if you use a return statement in the required file. Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/#findComment-1316030 Share on other sites More sharing options...
RON_ron Posted February 9, 2012 Author Share Posted February 9, 2012 Thanks you PFMaBiSmAd & Pikachu2000! that solved the problem. Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/#findComment-1316039 Share on other sites More sharing options...
RON_ron Posted February 9, 2012 Author Share Posted February 9, 2012 How do I put this in my email code? When i use the code below, it shows the URL as "1"? <?php $link = require( dirname( __FILE__ ) . '/../../../../essentials/myData.php' ); return ($link); //rest of the code <a href='http://www.web.com.au/'".$link."' target='_blank'> <img src='http://www.web.com.au/dir/image_mail.gif' style='max-width:110px;' mc:label='image' mc:edit='tiwc200_image00' /></a> //rest of the code ?> Quote Link to comment https://forums.phpfreaks.com/topic/256712-an-extra-1-is-appearing/#findComment-1316047 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.