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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT