a simple php include in html would look like this
PHP Code:
<html>
<head>
</head>
<body>
<?php include 'header.php'; ?>
-- your main body of the page in html here---
<?php include 'footer.php'; ?>
</body>
</html>
or you can even use the require_once or require comand as well
PHP Code:
<?php require_once 'file.php'; ?>
other than doing it for headers or footers, you can use it for menus, sidebars, or just about anything, there are some nice php snippets that people who dont know php can use to make there design easeir, here are some more of the common ones:
Time and Date:
PHP Code:
// Prints something like: Monday 15th of August 2005 03:12:46 PM
echo date('l dS \of F Y h:i:s A');
// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
/* use the constants in the format parameter */
// prints something like: Mon, 15 Aug 2005 15:12:46 UTC
echo date(DATE_RFC822);
// prints something like: 2000-07-01T00:00:00+00:00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
// prints something like: Wednesday the 15th
echo date("l \\t\h\e jS");
find info about your php install on your server:
PHP Code:
<?
phpinfo();
?>
Sending An E-mail, this is a very baisc mail, but if anyone wants, I can post some other more secure, php functions, with variables.
PHP Code:
$to = "php@email.com";
$subject = "PHP Is Great";
$body = "PHP is one of the best scripting languages around";
$headers = "From: webmaster@email.com\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
Show a visitors or users info on a page:
PHP Code:
// show users IP, there are a couple ways depending on your version/setup of php
// number 1
<?php echo $REMOTE_ADDR; ?>
// number 2
<? echo getenv('REMOTE_ADDR'); ?>
// number 3
<?php echo $HTTP_SERVER_VARS['REMOTE_ADDR'];?>
// show browser
<? echo $_SERVER['HTTP_USER_AGENT']; ?>
I have many more, if anyone wants, I can put up some tutorials on easy to use and make php scripts, like stat counters, mail forms, and what not.