Java Script and PHP
am 22.12.2007 20:33:10 von HardySpicer
I have an application that uses Google Maps. This works fine but I ned
to read a file. I can do this in PHP but how to mix PHP with Java
Script? Do they live together or do I need to end each block of script
then start the php - then end it etc.
regards
Hardy
Re: Java Script and PHP
am 22.12.2007 21:05:24 von Macca
PHP is server side and is converted to HTML by the time it reaches the
client (browser). JavaScript is client side and is interpreted by the
client (browser) on the other side.
Thus, you can write javascript with PHP but you cant write PHP with
javascript.
e.g.
echo '
--
www.panoye.com :: virtual tour
Re: Java Script and PHP
am 23.12.2007 14:43:35 von Jonas Werres
> Or save a file named myscript.js.php. In the file you can use both
> javascript and php. For example, you can write:
>
> alert( )
>
> and then include it in your html with:
>
>
> src="myscript.js.php">
>
> --
> www.panoye.com :: virtual tour
This will be send with the wrong Header (normally text/html). You have
to add
header('Content-type: application/x-javascript');
Re: Java Script and PHP
am 23.12.2007 20:27:39 von Macca
On Dec 23, 1:43 pm, Jonas Werres wrote:
> > Or save a file named myscript.js.php. In the file you can use both
> > javascript and php. For example, you can write:
>
> > alert( )
>
> > and then include it in your html with:
>
> >
> > src="myscript.js.php">
Its still the same thing. The PHP is interpreted on the server before
the javascript on the client,
so, what is sent to the client is actually
alert(27)
it's the same as having a file called script.php and writing
Re: Java Script and PHP
am 24.12.2007 11:20:07 von Betikci Boris
On Dec 22, 9:33=A0pm, HardySpicer wrote:
> I have an application that uses Google Maps. This works fine but I ned
> to read a file. I can do this in PHP but how to mix PHP with Java
> Script? Do they live together or do I need to end each block of script
> then start the php - then end it etc.
>
> regards
>
> Hardy
ANOTHER USAGE:
Alternative PHP usage
";
echo "";
echo "";
die();
}
else {?>
alert("Ok variable is true");