简体   繁体   English

如何使用php变量作为java applet的参数

[英]how to use a php variable as a parameter for java applet

I want to use a php session variable as a parameter when I call a java applet. 我要在调用Java小程序时使用php会话变量作为参数。 I have seen answers to this on the net but they do not work on my machine. 我已经在网上看到了有关此问题的答案,但是它们在我的计算机上不起作用。 The html file and applet produce the literal string instead of the content of the variable. html文件和applet生成文字字符串,而不是变量的内容。

Here is the code that I have used. 这是我使用的代码。

<param name="param1" value="<?php echo $thevar;?>" />

I have also tried variations on this to no avail 我也尝试过这种变化无济于事

<?php echo'<param name="param1" value="$thevar" />';?>
<param name="param1" value="<?php echo($thevar);?>" />
<param name="param1" value=<?php echo $thevar;?>/>
<?php echo '<param name="param1" value=".$name1.">';?>
echo '<PARAM NAME="name" VALUE="'
. htmlspecialchars($name1, ENT_QUOTES)
. '">';

The file is an html file. 该文件是一个html文件。 Should it be a php file? 应该是一个php文件吗? I created a php file with the same code, but my machine did not know which program to use to run it. 我用相同的代码创建了一个php文件,但是我的机器不知道该使用哪个程序来运行它。 It did not run in firefox. 它没有在Firefox中运行。

I start the session prior to having any html. 我开始使用任何HTML之前的会话。

Some sites recommend that the HTML param tag end with /> and others end it with >, which is correct? 有些网站建议HTML param标签以/>结尾,而其他网站则以>结尾,这是正确的吗?

Do I need to escape some characters with the backslash? 我是否需要使用反斜杠转义一些字符?

The file is an html file. 该文件是一个html文件。 Should it be a php file? 应该是一个php文件吗?

Yes. 是。 PHP structures are not evaluated in HTML, just dumped as-is. PHP结构不是用HTML评估的,而是按原样转储的。


(Unless you have some server-side cleverness that serves PHPs with an HTML extension.) (除非您有一些服务器端的聪明之处,可以为带有HTML扩展名的PHP提供服务。)

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

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