Yes that is exactly what I want to do. The txt file is only accessible locally on my server, and the client browser should never see the php command.
However, I can't figure out how to set the php server to read .js files too. Edit: It sounds like overkill maybe, but if it's easy it might be very nice, since I don't use a CMS but would like to simulate some of it's functionality (server-side).
This was a nice idea. It didn't work because the text file has newlines in it that are not escaped. I fixed it like this:
Index.php:
<script type="text/javascript">var textFileInfo= "<?php echo str_replace(array("\r\n","\n","\r"),"\\n\"+\"",file_get_contents('exampledatafile1.txt')) ?>";</script>
<script language="javaScript" type="text/javascript" src="myJSCode.js"></script>
Which works nicely like it should. The only thing is my index.php will become very ugly once I upload all the files this way. And it would be nicer to mod the filename in the script that uses it.
Well, it works, I'm happy enough with this, but any suggestions to make it nicer/prettier are very welcome, I'm still trying to learn. Thanks a lot for the answers!!!