在echo中嵌套JS [英] nesting JS in echo's

查看:74
本文介绍了在echo中嵌套JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


html编码器在这里,新的和害怕的PHP !!

aaaaaa!


我试图掩埋一个JS脚本来旋转照片,在我从

html转换成php的页面中。

转换进展顺利,它是使用php会话cookie来停止每个会话重复嵌入的视频文件

i修改php代码,如果会话cookie显示静止图片价值

是零。


工作正常。


以为我会尝试整合经过测试的真实JS图像随机旋转脚本

进入echo命令,但问题是单引号的语法

和doc.write和变量序列中需要的双引号JS。


i试图逃避双引号(我的回音用双引号),但没有

有用。


这里是我在PHP尾端使用的JS CODE。 " picnumber"是

变量,持有随机分配的数字选择图片。


任何帮助非常感谢..

+++ +++++++++++++++++++++++++ + $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 2''>

<! - 开始

document.write(\"''< img src =''images / swap /'' + picnumber +''.jpg''> \");

//结束 - >

< / script>

; }


++++++++++++++++++++++++++++++++++++++++ b谢谢

解决方案

Request-1< he *** @ you.comwrote:


嗨伙计们,


html编码器在这里,新的和害怕的PHP !!

aaaaaa!


我试图掩埋一个JS脚本来旋转照片,在我从

html转换成php的页面中。

转换进展顺利,它是使用php会话cookie来停止每个会话重复嵌入的视频文件

i修改php代码,如果会话cookie显示静止图片价值

是零。


工作正常。


以为我会尝试整合经过测试的真实JS图像随机旋转脚本

进入echo命令,但问题是单引号的语法

和doc.write和变量序列中需要的双引号JS。


i试图逃避双引号(我的回音用双引号),但没有

有用。


这里是JS CODE i在我的PHP的尾端使用。 " picnumber"是

变量,持有随机分配的数字选择图片。


任何帮助非常感谢..


+++++++++++++++++++++++++++++ ''JavaScript1.2''>

<! - 开始

document.write(\"''< img src =''images / swap /''+ picnumber +''.jpg''> \");

//结束 - >

< / script>

" ;; }


++++++++++++++++++++++++++++++++++++++++ b谢谢



它会起作用,但一次做一行可能更容易,例如

这些示例行来自a做JS的PHP页面:


echo"< script LANGUAGE =''JavaScript''> \ n";


echo"< INPUT type = \" hidden\"命名= \" clock\"大小= \" 3\"值= \" \"> \ n" ;;

-

Jim Pennino


删除.spam.sux回复。


11月7日,6:58 * pm,Request-1。 < he ... @ you.comwrote:


嗨伙计们,


html编码器在这里,新的和害怕的* php !!

aaaaaa!


我试图在我从

html到php。

转换进行得很顺利,就是用一个php会话cookie来阻止

重复一个嵌入式视频文件会话基础;

i修改了php代码,如果会话cookie价值

为零,则显示静止图片。


工作正常。


以为我会尝试将经过测试的真实JS图像随机旋转器脚本

集成到echo命令中,但问题在于语法单引号

和JS中doc.write和变量序列所需的双引号。


i尝试转义双引号(我的echo使用双引号) ,但没有

有用。


这里是JS CODE我在PHP的尾端使用。 *" picnumber"是

变量,持有随机分配的数字选择图片。


任何帮助非常感谢..


+++++++++++++++++++++++++++++ language =''JavaScript1.2''>

* * * *<! - 开始

* * document.write(\"''< ; img src =''images / swap /''+ picnumber +''.jpg''> \");

* * //结束* - >

< / script>

* *" ;; }


++++++++++++++++++++++++++++++++++++++++ b谢谢



你可以这样做:


{?>


<! - 不需要转义 - >


< script type =''text / javascript''>

document.write ("< img src =''images / swap /''+ picnumber +''.jpg''>");

< / script>


<?php}


是picnumber一个JavaScript或PHP可验证?


Thomas


11月7日,7:16 * pm,703designs< thomasmal .. 。@ gmail.comwrote:


11月7日,6:58 * pm,Request-1 < he ... @ you.comwrote:


嗨伙计们,


html编码器在这里,新的和害怕的PHP !!

aaaaaa!


我试图埋葬一个JS脚本来旋转照片,在我转换为

html的页面中php。

转换进展顺利,就是使用php会话cookie来停止每个会话重复嵌入的视频文件

;
如果会话cookie值

为零,
i修改了php代码以显示静止图片。


工作正常。


以为我会尝试将经过测试的真实JS图像随机旋转脚本

集成到echo命令中,但是问题是单引号的语法

和doc.write和JS中的变量序列所需的双引号。


我尝试转义双引号(我的回音使用双引号),但是tono

有效。


here'是我在PHP尾部使用的JS CODE。 *" picnumber"是

变量,包含随机分配的数字,用于选择图片。


任何帮助非常感谢..


++++ +++++++++++++++++++++++


* *< script language =''JavaScript1.2''>

* * * *< ! - 开始

* * document.write(\"''< img src =''images / swap /''+ picnumber +''.jpg''> \ ");

* * //结束* - >

< / script>

* *" ;; }


++++++++++++++++++++++++++++++++++++++++++++++++ b


谢谢



你可以这样做:


{?>


<! - 无需转义 - >


< script type =''text / javascript''>

* * document.write("< img src =''images / swap /''+ picnumber +''.jpg''>"); < br $> b $ b< / script>

<?php}


是picnumber一个JavaScript或PHP可验证?


Thomas



你也可以使用heredoc:
http:// us3.php.net/manual/en/languag...syntax.heredoc

<?php

echo<< < DOESNTMATTERWHATTHISSAYS


<! - 无需转义 - >

< script type =''text / javascript''>

document.write("< img src =''images / swap /''+ picnumber +''.jpg''>");

< ; / script>

DOESNTMATTERWHATTHISSAYS;

//不要缩进上面的线路


Thomas


hi folks,

html coder here, new and terrified * of php!!
aaaaaa!

i''m trying to bury a JS script to rotate a photo, in a page i converted from
html to php.
the conversion went well, it was to use a php session cookie to stop the
repeating of an embedded video file on a per session basis;
i amended the php code to display a still pic if the session cookie value
was nil.

worked fine.

thought I''d try integrating a tested and true JS image random rotator script
into the echo command, but the problem was the syntax of the single quotes
and double quotes needed in the doc.write and variable sequences in the JS.

i tried escaping the double quotes (my echo used double quotes), but to no
avail.

here''s the JS CODE i use in the tail end of my PHP. "picnumber" is the
variable holding the randomly assigned number that chooses the picture.

any help much appreciated..
++++++++++++++++

{ echo "

<script language=''JavaScript1.2''>
<!-- begin
document.write(\"''<img src=''images/swap/''+ picnumber + ''.jpg''>\");
// end -->
</script>
"; }

++++++++++++++++++++++++++

thanks

解决方案

Request-1 <he***@you.comwrote:

hi folks,

html coder here, new and terrified * of php!!
aaaaaa!

i''m trying to bury a JS script to rotate a photo, in a page i converted from
html to php.
the conversion went well, it was to use a php session cookie to stop the
repeating of an embedded video file on a per session basis;
i amended the php code to display a still pic if the session cookie value
was nil.

worked fine.

thought I''d try integrating a tested and true JS image random rotator script
into the echo command, but the problem was the syntax of the single quotes
and double quotes needed in the doc.write and variable sequences in the JS.

i tried escaping the double quotes (my echo used double quotes), but to no
avail.

here''s the JS CODE i use in the tail end of my PHP. "picnumber" is the
variable holding the randomly assigned number that chooses the picture.

any help much appreciated..
++++++++++++++++

{ echo "

<script language=''JavaScript1.2''>
<!-- begin
document.write(\"''<img src=''images/swap/''+ picnumber + ''.jpg''>\");
// end -->
</script>
"; }

++++++++++++++++++++++++++

thanks

It will work, but it is probably easier to do a line at a time, as in
these example lines from a PHP page that does JS:

echo "<script LANGUAGE=''JavaScript''>\n";

echo "<INPUT type=\"hidden\" name=\"clock\" size=\"3\" value=\"\">\n";
--
Jim Pennino

Remove .spam.sux to reply.


On Nov 7, 6:58*pm, "Request-1" <he...@you.comwrote:

hi folks,

html coder here, new and terrified * of php!!
aaaaaa!

i''m trying to bury a JS script to rotate a photo, in a page i converted from
html to php.
the conversion went well, it was to use a php session cookie to stop the
repeating of an embedded video file on a per session basis;
i amended the php code to display a still pic if the session cookie value
was nil.

worked fine.

thought I''d try integrating a tested and true JS image random rotator script
into the echo command, but the problem was the syntax of the single quotes
and double quotes needed in the doc.write and variable sequences in the JS.

i tried escaping the double quotes (my echo used double quotes), but to no
avail.

here''s the JS CODE i use in the tail end of my PHP. *"picnumber" is the
variable holding the randomly assigned number that chooses the picture.

any help much appreciated..

++++++++++++++++

{ echo "

* *<script language=''JavaScript1.2''>
* * * * <!-- begin
* * document.write(\"''<img src=''images/swap/''+ picnumber + ''.jpg''>\");
* *// end *-->
</script>
* *"; }

++++++++++++++++++++++++++

thanks

You can do this:

{ ?>

<!-- No escaping required -->

<script type=''text/javascript''>
document.write("<img src=''images/swap/'' + picnumber + ''.jpg''>");
</script>

<?php }

Is "picnumber" a JavaScript or PHP veriable?

Thomas


On Nov 7, 7:16*pm, 703designs <thomasmal...@gmail.comwrote:

On Nov 7, 6:58*pm, "Request-1" <he...@you.comwrote:

hi folks,

html coder here, new and terrified * of php!!
aaaaaa!

i''m trying to bury a JS script to rotate a photo, in a page i convertedfrom
html to php.
the conversion went well, it was to use a php session cookie to stop the
repeating of an embedded video file on a per session basis;
i amended the php code to display a still pic if the session cookie value
was nil.

worked fine.

thought I''d try integrating a tested and true JS image random rotator script
into the echo command, but the problem was the syntax of the single quotes
and double quotes needed in the doc.write and variable sequences in theJS.

i tried escaping the double quotes (my echo used double quotes), but tono
avail.

here''s the JS CODE i use in the tail end of my PHP. *"picnumber" is the
variable holding the randomly assigned number that chooses the picture.

any help much appreciated..

++++++++++++++++

{ echo "

* *<script language=''JavaScript1.2''>
* * * * <!-- begin
* * document.write(\"''<img src=''images/swap/''+ picnumber + ''.jpg''>\");
* *// end *-->
</script>
* *"; }

++++++++++++++++++++++++++

thanks


You can do this:

{ ?>

<!-- No escaping required -->

<script type=''text/javascript''>
* * document.write("<img src=''images/swap/'' + picnumber + ''.jpg''>");
</script>

<?php }

Is "picnumber" a JavaScript or PHP veriable?

Thomas

You can also use "heredoc":
http://us3.php.net/manual/en/languag...syntax.heredoc

<?php
echo <<<DOESNTMATTERWHATTHISSAYS

<!-- No escaping required -->
<script type=''text/javascript''>
document.write("<img src=''images/swap/'' + picnumber + ''.jpg''>");
</script>
DOESNTMATTERWHATTHISSAYS;
// Don''t indent the above line line

Thomas


这篇关于在echo中嵌套JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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