• Skip to Content
  • Home
  • Previous Page: Creating A Vibrant Web Page Template
  • Next Page: Wiring A Home For Ethernet Network Access
  • Up: Computers and Technology
  • Access Options
  • Site Index
  • Print this page
  • Share Page
  • Mobile

LesTout Logo
  • Connect with experts
  • Read the latest articles and news
  • Become an expert and share practical advice
LesTout is an online network of helpful guides, eager to share their Expert Advice with you! Learn more or Join LesTout Community - It's Free!

Your First PHP Based Web Page

Picture of: C Criswell
From : C Criswell
Your guide for : Computers and Technology
Published in : Computers and Technology
Login or  Sign Up Now to participate in our community and subscribe to our Newsletters.
  • Posted on 06-23-2008
  • Views 40
  • Rating 0 (0 votes)
Print this page

Incorporating a bit of PHP code into a web page can turn a boring, static web page into a dynamic, cohesive part of an entire web site.  PHP uses simple terms and syntax to tell the web server to insert dynamic data into a web page before it is sent out to the viewer.  This brief PHP tutorial shows you just how simple it can be to get started adding PHP to a web page, and also gives you some resources to visit to learn more.

The most basic way to use PHP is to have it create simple text blocks to be displayed on the web page.  Every PHP code section on a web page begins with:

<?PHP

and ends with

?>

Between these two statements goes the rest of the PHP code.  For this first example we will create a page that simply says "Hello!" to our visitors.

<?PHP
echo "Hello!";
?>


When uploaded to a web server and then opened in a web browser a page with that bit of code will output a blank white page with the word "Hello!" written at the top.  Pretty basic, yes, but when we expand the statement to include some other information the information suddenly becomes dynamic:

<?PHP
$todayDate = date("Y/m/d");
echo "Hello!  Today is ",$todayDate;
?>


This bit of code asks the computer for today's date and stores it in a variable known as $todayDate.  The echo statement then pulls that date in and adds it to the text on the page after the other words, resulting in a page that says:

Hello!  Today is 2008/07/06

Additional commands and manipulations can be made to the code to actually make it output things in HTML formatting, allowing a web page to update itself based on whatever information you tell it to gather.  The example above is the most simplistic of PHP web pages.  The true power and usefullness of PHP comes into play when using PHP together with a MySQL database.  At this point such things as content management systems become possible, and any limit to the usefullness and flexibility of a web site goes away.  If you are willing to give it a little time and study, learning PHP and incorporating it into your web site can be a very fun and worthwhile venture.

All fields mark * are required.

Click here to post new commentsLeave a Comment

Click here to close rateRate this Article

Click here to open feedback formContact this Member

Click here to open tell a friend formTell a Friend

Click here for link of this pageLink to this Article


Already have a Lestout account? Login here.

Free Newsletters

Subscribe now for the Lestout Newsletter!