How to share/use a variable between PHP and HTML on the same page ?

How to share/use a variable between PHP and HTML on the same page ?

am 19.11.2007 08:40:15 von Pradnya

How to share/use a variable between PHP and HTML on the same page ?
( i.e. without using GET/ POST etc.... )

Is it possible ?

And what about same with PHP and JavaScript ?

Re: How to share/use a variable between PHP and HTML on the same page

am 19.11.2007 09:19:53 von AndreHebben

On Nov 19, 8:40 am, pradnya wrote:
> How to share/use a variable between PHP and HTML on the same page ?
> ( i.e. without using GET/ POST etc.... )
>
> Is it possible ?
>
> And what about same with PHP and JavaScript ?

You can share through from PHP to HTML just one way (server->client)
through a hidden input field
Example:
/>
For Javascript it is then possible to access it.

For two way communication you should really look into AJAX/ JSON
principles

Re: How to share/use a variable between PHP and HTML on the samepage ?

am 19.11.2007 09:41:23 von Toby A Inkster

pradnya wrote:

> How to share/use a variable between PHP and HTML on the same page ?
> ( i.e. without using GET/ POST etc.... )
>
> Is it possible ?

Not sure what you mean. HTML doesn't have "variables".

> And what about same with PHP and JavaScript ?

Depending on what you want to achieve there are several techniques. You
can use PHP to generate the Javascript in the first place, which allows
PHP to populate the script's variables with certain values. Or a piece of
Javascript can communicate with a PHP script using AJAX.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 12 days, 15:35.]

USD/EUR Exchange Rate Graph
http://tobyinkster.co.uk/blog/2007/11/18/usd-eur/