I have some string output in php and want to call it from java: <script language="JavaScript" type="text/javascript" src="http://mysite/myphp.php"></script> Code (markup): or maybe with <script language="JavaScript" type="text/javascript"> document.open('http://mysite/myphp.php') </script> Code (markup): so users can use it in html files. how to make output in php and how call it from html... i realy dont know java..
You cannot include php pages in HTML like that. There are serval ways. 1. iFrames (eww) 2. Add HTML to the list of extensions that php will parse and put your code there. 3. Change the .html extension to .php and put your code there. 4. You can call the content with AJAX and place it in your HTML document. (Not google friendly) The best method would be either method 2 or 3. You can do that with htaccess for example. AddType x-httpd-php .php .htm .htm Code (markup): EDIT: You can also include files with SHTML <!--#include FILE="filename.php"--> Code (markup): Don't rely on Javascript cause not all users have it enabled.
my preferred way: <script language="JavaScript" type="text/javascript"> dummyimage = new Image(); dummyimage.src = http:www.yourdomain.com/yourfile.php </script> Code (markup): you create a dummy image and cheat javascript to think that the source of the image is a php file - the code in the php file gets called well and good!