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  
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 - 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

    - 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 3 hosted by Hostway