简体   繁体   English

我需要编写PHP文件来重定向html请求的帮助。

[英]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. 基本上,我的网站上有一个html代码段,需要执行URL。 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. 我希望它不仅可以在空间中写入URL,还可以获取服务器上文本文件的内容,还可以添加另一个文件的内容。

here is the HTML snippet with the line which needs the text on the 4th line: 这是带有代码行的HTML代码段,该代码行需要第4行上的文本:

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? 我猜你的意思是抓取文件的内容并将文本插入js代码片段以实现自动化?

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. 如果要使用文本作为数据存储,则应使用xml并使用新版本php中标配的simplexml库。

W3 schools xml page W3学校xml页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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