PHP
  Home arrow PHP arrow Page 2 - PHP 101 (Part 1) - Secret Agent Man
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP 101 (Part 1) - Secret Agent Man
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 34
    2000-07-31

    Table of Contents:
  • PHP 101 (Part 1) - Secret Agent Man
  • Bond...James Bond
  • A Case Of Identity
  • The Toy Shop
  • Weapons To Die For

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP 101 (Part 1) - Secret Agent Man - Bond...James Bond


    (Page 2 of 5 )

    Once you've configured your Web server to parse PHP pages, it's time to test it and see if everything's working as advertised. The simplest way to do this is to pop open your favourite text editor and create a file containing these lines of code:

    <?php phpinfo(); ?>
    Save the file with the extension .php - for example, "test.php"

    Now, start up your Web browser and point it to the file you just saved - for example, http://localhost/test.php - and you'll see a page filled with what at first glance appears to be gibberish, but on closer inspection will reveal itself to be a list of internal PHP variables. The values of most of these variables can be modified by altering the "php.ini" file that ships with every distribution of PHP. For beginners, the default values are more than sufficient to work with.

    There's one essential concept that you need to get your mind around before we proceed further. Unlike CGI scripts, which require you to write code to output HTML, PHP lets you create embed PHP code in regular HTML pages, and execute the embedded PHP code when the page is requested.

    These embedded PHP commands are enclosed within special start and end tags - here's what they look like:

    <?php ... PHP code ... ?> or the shorter version <? ... PHP code ... ?>
    Here's a simple example which demonstrates how PHP and HTML can be combined:

    <html> <head> <title>Bonding With PHP</title> </head> <body> So who do you think you are, anyhow? <br> <?php // this is all PHP code echo "<b>The name's Bond...James Bond!</b>"; ?> </body> </html>
    And if you browse to this page through your browser and take a look at the HTML source, this is what you'll see:

    <html> <head> <title>Bonding With PHP</title> </head> <body> So who do you think you are, anyhow? <br> <b>The name's Bond...James Bond!</b> </body> </html>
    Every PHP statement ends in a semi-colon - this convention is identical to that used in Perl, and omitting the semi-colon is one of the most common mistakes newbies make. It's also possible to add comments to your PHP code, as we've done in the example above. PHP supports both single-line and multi-line comment blocks - take a look:

    <?php // this is a single-line comment /* and this is a multi-line comment */ ?>

    More PHP Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway