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

Try something like this:

 

<?php

foreach(glob("*.jpg") as $imagefile)

{ 

   echo "<img src=$imagefile title='$imagefile'>";

}

?>

 

The variable references must be within the areas that PHP is able to parse.
PHP is entirely server-side, the client's browser has no idea what
$imagefile is. It just thinks it is text.

 

Best regards,
Rajib Momen

President, Director of I.T.
Boston Computing Network
http://www.bostoncomputing.net 

  _____  

From: www-html-request@w3.org [mailto:www-html-request@w3.org] On Behalf Of
jim sullivan
Sent: Friday, July 15, 2005 3:19 PM
To: www-html@w3.org
Subject: PHP and HTML, and how to access PHP variables from HTML

 

 

This is a general question on how to reference script variables from HTML, 

although the example I use is with PHP.  Can someone point me to an example 

that shows how to do this ?  

 

I want to use the PHP file system functions to read the contents(image
files) of a directory, 

and then reference the PHP variable from HTML to display the image. 

Here is an example that does NOT work but it should show what I am trying to
do. 

 

<?php

foreach(glob("*.jpg") as $imagefile)

{ 

?> 

<img src=$imagefile title="$imagefile"> 

<?php

}

?>

 

 

thanks

 

Received on Sunday, 17 July 2005 17:05:57 UTC