简体   繁体   中英

I need help writing a php file to redirect a html request.

This is a tricky problem as it is multi layered, but I'm sure there will be folks who can help me.

Basically, I have a html snippet on my website which requires a URL to execute. Instead of just writing the URL in the space, I would like it to get the contents of a text file on my server, but also add the contents of another.

here is the HTML snippet with the line which needs the text on the 4th line:

1## <script type="text/javascript" src="mrp.js"></script>
2## <script type="text/javascript">
3## MRP.insert({
4## 'url':'TEXT FROM FILES HERE',
5## 'codec':'mp3',
6## 'volume':65,
7## 'autoplay':false,
8## 'buffering':5,
9## 'title':'Radio Zaum',
10## 'welcome':'WELCOME TO...',
11## 'bgcolor':'#FFFFFF',
12## 'skin':'simple-gray',
13## 'width':300,
14## 'height':122
15## });
16## </script>

I hope someone can help me do this pretty simple, yet frustrating task! Thanks!!

I'm not sure what you're asking but when you say

"I would like it to get the contents of a text file on my server" 

i'm guessing you mean to grab contents of a file and insert the text in the js snippet to automate?

Your line of code:

2## <script type="text/javascript">
3## MRP.insert({
4## 'url':'TEXT FROM FILES HERE',

Possible solution: use

echo $scrape_file = file_get_contents("the_file.txt or html");

The output of the code above will be: This is a test file with test text.

2## <script type="text/javascript">
3## MRP.insert({
4## 'url':'<?=$scrape_file?>',

If you want to use text as a store of data, you should use xml and use the simplexml library that comes standard in the new versions of php.

W3 schools xml page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM