Page 1 of 1

Using java vars in php?

Posted: Wed Apr 16, 2003 11:36 am
by penguinboy
is it possible??
if it is how is it done?

Posted: Wed Apr 16, 2003 11:36 am
by twigletmac
Just to check first off - Java variables or JavaScript variables? What exactly are you trying to do?

Mac

Posted: Wed Apr 16, 2003 11:40 am
by volka
php: server-side (almost always)
javascript: client-side

They do not share the same context but you can send the values of javascript variables with a http-request
e.g.

Code: Select all

<html>
	<head>
		<script language="javascript" type="text/javascript">
			var posX=1;
			var posY=2;
			function newRequest()
			&#123;
				document.location = "http://localhost/test.php?x="+posX+"&y="+posY;
				return true;
			&#125;
		</script>
	</head>
	<body>
		<button onClick="javascript:newRequest()">click</button>
	</body>
</html>
edit: ah, right Java. That could be server-side, too.....

Posted: Wed Apr 16, 2003 11:51 am
by daven
I think it is possible to pass variables between the languages if you use included functions. I have never actually tried this myself, but I have been told it works.

ie--
<?php
include "compiledJavaProgram";
java_function($parameters);
?>