如何返回文件 [英] How to return a file

查看:95
本文介绍了如何返回文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在某些HTML代码中,我有以下内容:


< script type =''text / javascript' 'src =''foo.js''>< / script>


但是,我想用br替换''foo.js'' />
" bar.php?file = foo"并让bar.php回显foo.js回到脚本

元素。这可能吗?

Hello all,

In some html code I have the following:

<script type=''text/javascript'' src=''foo.js''></script>

However, I''d like to replace ''foo.js'' with something like
"bar.php?file=foo" and have bar.php echo foo.js back to the script
element. Is this possible?

推荐答案

是。

将foo.js文本放在bar.php中文件或从数据库或

文本文件中读取它并让php吐出来。无论你喜欢什么。


然后,当bar.php收到带有

值foo的查询字符串变量文件时,让它首先打印出类型的使用此代码输出:


header(''Content-type:text / javascript'');


然后打印出来foo.js的内容(不管你有没有把它们存放起来)


HTH

-Joe


10月16日晚上10点41分,布莱恩 < BTRichard ... @ gmail.comwrote:
Yes.
Put the foo.js text in the bar.php file or read it from a database or
text file and have php spit it out. Whatever suits your fancy.

Then, when bar.php receives the query string variable file with the
value foo, have it first print the type of the output with this code:

header(''Content-type: text/javascript'');

and then have it print the contents of foo.js (whereever you may have
stored them)

HTH
-Joe

On Oct 16, 10:41 pm, "Bryan" <BTRichard...@gmail.comwrote:

大家好,


在某些html代码中我有以下内容:


< script type =''text / javascript''src =''foo.js''>< / script>


但是,我想将''foo.js'替换成

" bar.php?file = foo"并让bar.php回显foo.js回到脚本

元素。这可能吗?
Hello all,

In some html code I have the following:

<script type=''text/javascript'' src=''foo.js''></script>

However, I''d like to replace ''foo.js'' with something like
"bar.php?file=foo" and have bar.php echo foo.js back to the script
element. Is this possible?


2006年10月16日19:41:14 -0700,布莱恩 < BT ********** @ gmail.comwrote:
On 16 Oct 2006 19:41:14 -0700, "Bryan" <BT**********@gmail.comwrote:

>大家好,

在某些HTML中代码我有以下内容:

< script type =''text / javascript''src =''foo.js''>< / script>

但是,我想用'bar.php?file = foo"之类的东西替换''foo.js''。并让bar.php回显foo.js回到脚本
元素。这可能吗?
>Hello all,

In some html code I have the following:

<script type=''text/javascript'' src=''foo.js''></script>

However, I''d like to replace ''foo.js'' with something like
"bar.php?file=foo" and have bar.php echo foo.js back to the script
element. Is this possible?



首先,查询字符串不适用于包含,例如:

<?包括( bar.php文件= FOO?); }


但是,您可以创建一个函数:


函数foo(

First, a query string will not work with an include, like:
<? include(''bar.php?file=foo''); }

However, you can create a function:

function foo(


文件)

{

include(''
file)
{
include (''


这篇关于如何返回文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆