Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Is it possible to embedd php in javascript?

Javascript coding ..

Moderators: macek, egami, gesf

Is it possible to embedd php in javascript?

Postby Mazerman » Thu Jul 03, 2003 12:47 pm

Hi!

I would like to know if it is possible in some way to embedd php in javascript. I tryed the code below but it didn't work. Would be thankful if someone knows if it's possible or if there is another way of doing it:

Code: Select all
<script language="JavaScript" type="text/JavaScript">
<!--
function testJava()
{ //v2.0
   <?php
      echo "hello";
   ?>
   return 0;
}
//-->
</script>
Mazerman
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Jan 26, 2003 2:57 pm
Location: Sweden

Postby Redcircle » Thu Jul 03, 2003 1:10 pm

PHP executes on the server only. To get the results you want you will have to output JavaScript code with php.

Here's the code that will make your test program work.

Code: Select all
<script language="JavaScript" type="text/JavaScript">
<!--
function testJava()
{ //v2.0
   document.write("<?php
      echo "hello";
   ?>");
   return 0;
}
//-->
</script>
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby Mazerman » Thu Jul 03, 2003 4:48 pm

thnx!!
Mazerman
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Jan 26, 2003 2:57 pm
Location: Sweden


Return to JavaScript

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron