Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » PHP
 variables in PHP part 1
Pages: [1]   Go Down
  Print  
Author Topic: variables in PHP part 1  (Read 1048 times)
Daniel Franklin
TWI Hero
**********


Karma: 3
Offline Offline

Posts: 16647


View Profile Email
variables in PHP part 1
« Posted: September 26, 2007, 11:15:03 AM »


e = "shedboy";
$intDaysInWeek = 7;

In the first example the variable identifier in this example is $name and the string value "iain hendry" has been assigned to it . In the second example the variable identifier is $intDaysInWeek and the number 7 is assigned to it . Note that in the number example we do not surround the variable with quotes in this way PHP treats this as a numeric value but if we had put quotes round it then PHP would have treated it as a string.

Variable Naming

There are some guidelines to follow for naming variables in PHP and these are as follows .
1. All variable names must begin with a letter or underscore character .
2 . The name of the variable can be made up of numbers , letters , underscores but you cant use charcters like + , - , & , £ , * , etc
One important thing to note if you are coming from another programming language there is no size limit for variables .

Case Sensitivity

One thing that causes many hours of hair pulling and anguish is case sensitivity , PHP is case sensitive (some languages are not) . Here is an example of what I mean.

<?php
$myname = "shedboy";
echo $Myname";
?>

Now we all know what we want to do , declare a variable , assign it the value of "shedboy" and then print this on the screen but in this example we have mis-spelt the variable name , when run the following error is displayed on the screen.

Warning: Undefined variable: Myname in D:\testsample.php on line 3

Example

Using your favourite HTML editor enter the following

<?php
$url = "http://www.programmershelp.co.uk";
$rank = 1;
echo "Our favourite site is ".$url;
echo "
";
echo "It is numbered ".$rank;
?>

here is the output you should get
Our favourite site is http://www.programmershelp.co.uk
It is number 1

Articles Source - Free Articles

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.178 seconds with 24 queries.