Topic: how can i do php in jscript?

How can I do php in Javascript? (I know, that sounds really dumm, but...)

FluxBB - v1.4.8

Re: how can i do php in jscript?

I'm not exactly sure what you want to do wink
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?

3 (edited by lie2815 2007-03-11 19:29)

Re: how can i do php in jscript?

I want to execute some php comments in a .js file. Is that possible?

EDIT: Of course I mean commands, not comments.

FluxBB - v1.4.8

Re: how can i do php in jscript?

lie2815 wrote:

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 tongue

<?php
header('Content-Type: text/javascript');
// do php stuff
?>
function doJavascriptStuff(x)
{
  x = '<?php echo $somePhpVariable ?>';
  // do javascript stuff
  return x;
}

Easy stuff eh? smile

echo "deadram"; echo; fortune;

Re: how can i do php in jscript?

Thanks!
I'll try it and give you the report.

FluxBB - v1.4.8