PHP
  Home arrow PHP arrow Page 3 - 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 - A Case Of Identity
    ( Page 3 of 5 )

    Variables are the bread and butter of every programming language...and PHP has them too. A variable can be thought of as a programming construct used to store both numeric and non-numeric data; this data can then be used in different places in your PHP scripts.

    PHP supports a number of different variable types: integers, floating point numbers, strings and arrays. In many languages, it's essential to specify the variable type before using it; for example, a variable may need to be specified as type "integer" or type "array". Give PHP credit for a little intelligence, though - the language can automagically determine variable type by the context in which it is being used.

    Every variable has a name - in PHP, a variable name is preceded by a dollar [$] sign and must begin with a letter, optionally followed by more letters and numbers. For example,

    $popeye $one $INCOME are all valid PHP variables.

    Note that variable names in PHP are case sensitive - so

    $me

    is different from

    $Me

    or

    $ME

    Here's a simple example which demonstrates PHP's variables:


    <html> <head> <title>Bonding With PHP</title> </head> <body> So who do you think you are, anyhow? <br> <? // set up some variables $fname = "James"; $lname = "Bond"; ?> <b><? echo "The name's $lname...$fname $lname!"; ?></b> </body> </html>
    In this case, the variables $fname and $lname are first defined with string values, and then substituted in the echo() function call. Just as an aside...the echo() function is another important PHP function, and one that you'll be using a great deal over the next few lessons. It is commonly used to display output.

    Synonymous to echo() is print(), which does exactly the same thing - take a look at the example below, which demonstrates how to use it.


    <html> <head> <title>Bonding With PHP</title> </head> <body> So who do you think you are, anyhow? <br> <? // set up some variables $fname = "James"; $lname = "Bond"; ?> <? print("<b>The name's $lname...$fname $lname! </b>"); ?> </body> </html>
    Note how we've included the HTML <b> tag within the string to be displayed in this example...you can do this too. Really.

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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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