W3C home > Mailing lists > Public > www-html@w3.org > July 2005

Re: PHP and HTML, and how to access PHP variables from HTML

From: David Dorward <david@dorward.me.uk>
Date: Sat, 16 Jul 2005 12:39:17 +0100
To: jim sullivan <jim-sullivan@comcast.net>
Cc: www-html@w3.org
Message-ID: <20050716113917.GA9701@us-lot.org>

On Fri, Jul 15, 2005 at 03:19:11PM -0400, jim sullivan wrote:
>    This is a general question on how to reference script variables from HTML,

You don't. HTML is a document description language, not a programming
language. It has methods to hook scripting into it, but all the
variable handling must be done in the languges that are hooked not in
the HTML itself.

>    although the example I use is with PHP.

As far as I'm aware, client side support for PHP is nil.

>    <?php
>    foreach(glob("*.jpg") as $imagefile)
>    {
>    ?>
>    <img src=$imagefile title="$imagefile">
>    <?php
>    }
>    ?>

That would be an example of PHP being used to author an HTML document
on the fly. Since HTML is just a matter of the syntax of the output
format (You should have quotes around the value of the src attribute,
you are missing the required alt attribute, and the filename of the
image is unlikely to be useful advisory information), your question
would be better addressed to a PHP discussion list rather then one for
the discussion of the future design of HTML.

-- 
David Dorward                                      http://dorward.me.uk
Received on Saturday, 16 July 2005 11:45:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:03 GMT