Jump to content

nonaz

New Members
  • Posts

    2
  • Joined

  • Last visited

nonaz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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!!!
  2. Hi, im new to PHP and tried to do the following in my .js file: function ChangeTextbox(){ setTextBox(' <?php include "exampledatafile1.txt" ; ?> '); } It doesn't seem to work... Why? I expected the server to substitute the php tag with the text from my file. Instead the textbox gets the php statement itself. Is there an error? Is it because its a .js file, and my server doesn't look through that? Sorry if it's stupid, explanations are very welcome!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.