Oliverkahn Posted May 1, 2014 Share Posted May 1, 2014 when i try it on my server it create file with the name "0" instead of "testopic.php"... and display the text content as plane text instead of allowing me download the text in pdf and txt here is the code the txtdownload.php contains .. <?PHP $topic = "testtopic"; $topics = $topic + ".txt"; $msgg = "here goes the content"; $file_handle = fopen($topics , "w"); $file_contents = $msgg; fwrite($file_handle, $file_contents); fclose($file_handle); print "<a href='$topics'>download thread in txt</a>" ; ?> the pdfdownload.php contains the following code <?PHP $topic = "testtopic"; $topics = $topic + ".pdf"; $msgg = "content goes here"; $file_handle = fopen($topics , "w"); $file_contents = $msgg; fwrite($file_handle, $file_contents); fclose($file_handle); print "<a href='$topics'>download thread in pdf</a>" ; ?> thanks in advance... Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 1, 2014 Share Posted May 1, 2014 This statement: $topics = $topic + ".txt"; is using a mathematical plus operator. In doing so, PHP must convert the strings to their mathematical equivalent - which is the value zero. To 'concatenate' (put strings together), please use the period: $topics = $topic . ".txt"; Quote Link to comment Share on other sites More sharing options...
Oliverkahn Posted May 1, 2014 Author Share Posted May 1, 2014 thanks alot bro i will try it out Quote Link to comment 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.