kevonini Posted March 13, 2012 Share Posted March 13, 2012 It's been a while since I've dealt with text files and currently I am unable to write the contents of a variable to a text file, only the literal is being written. Should I be de-referencing or is this even possible? Also the problem is compounded by the fact that i also want to write the contents of a class display function into the text file. Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/ Share on other sites More sharing options...
ManiacDan Posted March 13, 2012 Share Posted March 13, 2012 You're probably single-quoting the variable, which won't work. that's all we can say without looking at code. Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326904 Share on other sites More sharing options...
kevonini Posted March 13, 2012 Author Share Posted March 13, 2012 That seemed to be it but now the newline feature is not working...would I need to modify something in the .ini file fwrite($handle, $name."\n"); Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326972 Share on other sites More sharing options...
Pikachu2000 Posted March 13, 2012 Share Posted March 13, 2012 How are you determining that \n isn't working; how are you displaying the data? Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326974 Share on other sites More sharing options...
kevonini Posted March 13, 2012 Author Share Posted March 13, 2012 inside the text file the data is being shown beside each other Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326975 Share on other sites More sharing options...
Pikachu2000 Posted March 13, 2012 Share Posted March 13, 2012 Try using the php end-of-line constant and see if that makes a difference. fwrite($handle, $name . PHP_EOL); Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326976 Share on other sites More sharing options...
kevonini Posted March 13, 2012 Author Share Posted March 13, 2012 Thanks ..that did the trick Quote Link to comment https://forums.phpfreaks.com/topic/258841-writing-variables-to-a-text-file/#findComment-1326979 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.