Using java vars in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Using java vars in php?

Post by penguinboy »

is it possible??
if it is how is it done?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just to check first off - Java variables or JavaScript variables? What exactly are you trying to do?

Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.....
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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);
?>
Post Reply