[nflug] PHP Inside HTML

Rob Dege livemotion at gmail.com
Thu Nov 20 01:10:17 EST 2008


I started to write a really long detailed explanation about how php works
and intertwines with HTML.  But then I realized that I was making the
question much more difficult than what it had to be.  So yes, php code can
be embeddedinto an HTML document, and here's a simple example. But as Tony
said, you have to rename the document with a .php extension so that your web
server knows to expect php code within the document.  Otherwise, your code
will appear as regular text.


------ snip ------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
 <TITLE><? echo "test page"; ?></TITLE>
<Body>

<p align=center>
Post 10 URL links using PHP
<?
// Something a lil more complex
 $loop=1;

 while ($loop <=10) {
  echo "  <a href=\"test-$loop.html\"> $loop </a>";

  if ($loop < 10) { echo " | \n"; }
  $loop++;
 }
?>
</p>

</Body>
</HTML>
------ snip ------


Hope this helps

-Rob

On Thu, Nov 20, 2008 at 12:17 AM, Robert Wolfe <nflug at muzzlethem.com> wrote:

> Hi all!
>
> I was wondering, can a PHP script be embedded anywhere inside an HTML file
> and if so, how?
> _______________________________________________
> nflug mailing list
> nflug at nflug.org
> http://www.nflug.org/mailman/listinfo/nflug
>



-- 
-Rob

Ben Franklin Quote: "They that can give up essential liberty to obtain a
little temporary safety deserve neither liberty nor safety."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nflug.org/pipermail/nflug/attachments/20081120/36c28d83/attachment.html


More information about the nflug mailing list