PHP
  Home arrow PHP arrow Page 3 - Programming PHP: A Beginner`s Guide
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? 
Google.com  
PHP

Programming PHP: A Beginner`s Guide
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 19
    2007-10-29


    Table of Contents:
  • Programming PHP: A Beginner`s Guide
  • PHP Means PHP: Hypertext Preprocessor
  • Variables
  • Working with Strings

  • 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


    Programming PHP: A Beginner`s Guide - Variables
    ( Page 3 of 4 )

    The best way to think of a variable is to think of a box. You store things in them. You can put stuff in them, take things out, move them around, and so forth. If you are an angry UPS guy who has some computer parts we just ordered, you can slam it on the floor and kick it a few times while glaring at all of the employees. Then you can politely ask for the signature and storm out (you know who you are!).

    Variables in PHP (and in programming languages in general) store data. Most programming languages are a real pain in the butt and make you define what type of data is being stored. Not PHP. In Soviet Russia, PHP tells you what type of data is in the variable!

    (Note: A special thanks to the great world-renowned comedian Yakov Schmirnoff).

    Here is how you work with variables:


    <html>

    <body>


    <?php

    $the_greatest = "James Payne";

    echo $the_greatest;


    ?>


    </body>

    </html>

    The above code store the string (or text) James Payne in a variable named $the_greatest. We then used echo and told it to print the value of $the_greatest. Which would result in:

      James Payne

    A note about naming variables. They must begin with either a letter or an underscore(_) and can only contain letters, numbers, and underscores. Spaces are not allowed. If you wish to use a two or more word name, use either of these methods: $string_name or $StringName. And lastly, a $ must precede the name of the variable, to let PHP know you are using a variable.



     
     
    >>> More PHP Articles          >>> More By James Payne
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek