Topic: how can i do php in jscript?
How can I do php in Javascript? (I know, that sounds really dumm, but...)
You are not logged in. Please login or register.
PunBB Forums → Programming → how can i do php in jscript?
How can I do php in Javascript? (I know, that sounds really dumm, but...)
I'm not exactly sure what you want to do
PHP is a server-side language, Javascript is a client-side language. You couldn't really include PHP code in your Javascript when it's passed to the user because they would have no way to interpret it. Do you want to dynamically generate bits of Javascript?
I want to execute some php comments in a .js file. Is that possible?
EDIT: Of course I mean commands, not comments.
I want to execute some php comments in a .js file. Is that possible?
You mean commands?
rename your .js file to .php, you probably also have to send the right header information, I think it's "header('Content-Type: text/javascript');" but don't take my word for it
<?php
header('Content-Type: text/javascript');
// do php stuff
?>
function doJavascriptStuff(x)
{
x = '<?php echo $somePhpVariable ?>';
// do javascript stuff
return x;
}
Easy stuff eh?
Thanks!
I'll try it and give you the report.
PunBB Forums → Programming → how can i do php in jscript?
Powered by PunBB, supported by Informer Technologies, Inc.