php在javascript文件中 [英] php in a javascript file
问题描述
我想知道是否可以在javascript
文件中使用php代码。我有一个带有大量函数的java文件,我想要
添加一个动作有php代码的地方。当我最初尝试
时,它没有用。这可能吗?是否有特殊技巧?
2005年11月18日11:38:50 -0800,在comp.lang.javascript中; gizoto316"
< d _ **** @ hotmail.com>写道:
|我想知道是否可以在javascript中使用php代码
|文件。我有一个带有一堆函数的java文件,我想要
|添加一个动作有PHP代码的地方。当我最初尝试
|它,它没有用。这可能吗?有没有特别的技巧?
php是一种服务器端语言,javascript是客户端的
语言,绝不是twain mix :-)
您可以使用IFrame或AJAX与php脚本进行通信。让
脚本返回结果。然后在你的网页中显示这个。
---------------------------------- -----------------------------
jn ****** @ yourpantsyahoo.com.au :脱掉裤子回复
-------------- -------------------------------------------------
gizoto316写道:
我想知道是否可以在javascript
文件中使用php代码。
这就是PHP解析脚本文件的方式<?php ...?>阻止
并生成JS / ECMAScript引擎可以解析的内容。
客户端。
我有一堆java文件它上面的函数
你可能意味着JavaScript是一个完全不同的东西。
我想添加一个动作有php代码的地方。
PHP解析过程在任何其他解析之前进行,包括
JS / ECMAScript引擎。
当我最初尝试过,它没有用。
不起作用是一个无用的错误描述。 [psf 4.11]
< http://jibbering.com/faq/>
这可能吗?
使用AJAX,您可以让JS / ECMAScript向PHP解析一个资源,以解析由$解析的资源。也许你正在寻找那个。
有没有特别的伎俩?
除了了解在何时何地发生的事情:没有。
PointedEars
Jeff North写道:
php是服务器端语言,javascript是客户端-side
语言,[...]
废话。服务器端J(ava)脚本
(例如ASP中的JScript [.NET])和客户端PHP。
PointedEars
I was wondering if it was possible to have php code in a javascript
file. I have a java file with a bunch of functions on it and I wanted
to add one where the action has php code in it. When i initially tried
it, it did not work. Is this possible? Is there a special trick?
On 18 Nov 2005 11:38:50 -0800, in comp.lang.javascript "gizoto316"
<d_****@hotmail.com> wrote:
| I was wondering if it was possible to have php code in a javascript
| file. I have a java file with a bunch of functions on it and I wanted
| to add one where the action has php code in it. When i initially tried
| it, it did not work. Is this possible? Is there a special trick?
php is a server-side language and javascript is a client-side
language, never the twain shall mix :-)
You could use and IFrame or AJAX to communicate to a php script. Let
the script return the results. Then display this within you web page.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
gizoto316 wrote:
I was wondering if it was possible to have php code in a javascript
file.
It is, in the way that PHP parses the script file for <?php ... ?> blocks
and generates content from that that a JS/ECMAScript engine can parse on
the client.
I have a java file with a bunch of functions on it
You probably mean JavaScript which is a completely different thing.
and I wanted to add one where the action has php code in it.
The PHP parsing process comes before any other parsing, including that of
the JS/ECMAScript engine.
When i initially tried it, it did not work.
"Does not work" is a useless error description. [psf 4.11]
<http://jibbering.com/faq/>
Is this possible?
With AJAX you can have JS/ECMAScript issue a HTTP request to
a resource parsed by PHP. Maybe you are looking for that.
Is there a special trick?
Apart from understanding what happens where and when: no.
PointedEars
Jeff North wrote:
php is a server-side language and javascript is a client-side
language, [...]
Nonsense. There is both server-side J(ava)Script
(e.g. JScript[.NET] in ASP) and client-side PHP.
PointedEars
这篇关于php在javascript文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!