[nflug] PHP Inside HTML

paul paul at paulcosta.com
Thu Nov 20 12:01:42 EST 2008


Robert,
Here are a couple of links that I found helpful
W3schools <http://www.w3schools.com/php/default.asp>
PHP manual <http://www.php.net/manual/en/>

Like Rob said, make sure that u save the file with the extension of .php 
instead of .htm/html.
The PHP code is enclosed in special start and end processing 
instructions |<?php| and |?>| that allow you to jump into and out of 
"PHP mode."

Whenever the browser parses or sees the <?php tag it parses what follows 
as php and not html
Make sure that u close the php statement when it ends ?>

<? is shorthand for <?php
Shorthand declarations only work when the php.ini file (located on the 
server)
 is set to accept shorthand

How to see what the php.ini file is set to.

Write a new file like this(don't include anything else) and save it as 
phpInfo.php
|<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?> |

Upload this php file to your server and then point your browser to to it
So if you have a domain like yourname.com,
point your browser to yourname.com/phpInfo.php
and it will list disclose all the information about your php.ini 
configuration settings

hope this helped


Rob Dege wrote:
> 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 
> <mailto: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 <mailto: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."
> ------------------------------------------------------------------------
>
> _______________________________________________
> nflug mailing list
> nflug at nflug.org
> http://www.nflug.org/mailman/listinfo/nflug
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nflug.org/pipermail/nflug/attachments/20081120/a9df1e2f/attachment.html


More information about the nflug mailing list