Hi i have just setup prototype window class,
but no i need to display php output in the windows,
( i want to include php in javascript.js )
so does anyone know how i can do this..
thanks
Hi i have just setup prototype window class,
but no i need to display php output in the windows,
( i want to include php in javascript.js )
so does anyone know how i can do this..
thanks
this is an example:
main page:
layout.php:PHP Code:<style type="text/css" media="screen">
<?php include('./includes/layout.php'); ?></style>
off the top of my head anyway?PHP Code:body,td,th {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
<?PHP echo "hello"; ?>
Last edited by supajason; 04-24-2008 at 09:46 AM.
supajason was here
sorry i did try it, but nothing i think its because im running it in a .js file and not .php so anymore ideas guys ??
Php is run ont he server, all php code is then removed and the reamining page sent to the client
Java Script is not ran on the server but just sent to the client. This means that:
php can generate java script (because php is run first)
javascript cannot generate php as it has already left the server.
eg this works:
but this doesn'tCode:</php echo "<script type=\"text/javascript\">\n". " document.write(\"Hello World!\");\n". "</script>\n"; ?>
I don't think the server parses .js files for php etc. Try making it a .php file and use the php header() function to set the content type to text/javascript. I think it's header("content-type: text/javascript");Code:<script type="text/javascript"> document.write("<?php echo \"Hello World\"; ?>"); </script>
Last edited by FireLancer; 04-24-2008 at 10:41 AM.
you need to do this:
add this to the main page:rename your js file to myjsfile.php, then in your new php(js) file you put:PHP Code:<script type="text/javascript" src="myjsfile.php"></script>
PHP Code:<?PHP
Header("content-type: application/x-javascript");
$serverIP=$_SERVER['REMOTE_ADDR'];
echo "document.write(\"Your IP address is: <b>" . $serverIP . "</b>\")";
?>
Last edited by supajason; 04-24-2008 at 10:30 AM.
supajason was here
Thanks for the help supajason, you out me on the right path, turn's out the the site runs off the index so i had to link to it there.