| Home > Computer & I'net > Variables... |
Variables | |
Once you have some information in variables, it can be sorted, organized, manipulated, and so forth. A variable name starts with a dollar $ symbol. After that you can use any combination of higher case letters A-Z, lower case letters a-z, or the underscore character _. Spaces are not allowed. Variable names are CaSe SeNsItIvE. If you are referring to a variable in your coding, make sure the name matches exactly. $MyVariableName is different from $myvariablename. Variable names should be easy to understand. Give some thought into the names. $fn or $FirstName or $first_name Which one looks more easier to understand and remember? There are three types of variables. Numbers, Strings, and Arrays. Number Variables may contain integers (regular positive or negative numbers) or floating-point (decimal) numbers. No fractions, letters, or extra decimals allowed. $integer_example = 5; $floating_point_example = 365.25; String Variables are word variables. They may contain number information and other variables. The values of string variables are contained within single quotes ' ' or double quotes " " depending on how you want to use them. $string_example_1 = "This is a test."; $string_example_2 = 'This is another test.'; $string_example_3 = "5"; $string_example_4 = "The value is $integer_example."; $string_example_5 = 'The value is $integer_example.'; The difference between single and double quotes is : Single quotes will print out the exact value of the string as is. Double quotes will transfer variable values into place before printing. echo "$string_example_4 <br />"; echo "$string_example_5"; Outcome : The value is 5.
The value is $integer_example. Arrays are groups of variables. These will be discussed in more detail on their own page. ----------------- Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission. | |
| Articles |
•Auto & Trucks•Business•Computer & I'net·General·Apache·CSS·Database·Hardware·HTML·Javascript&DHTML·Linux·MySQL·Operating System·Perl / CGIPHP·Programming·Publishing·Search Engines·Software Problems·SSI·Tips & Tricks·Utilities·Web Design•Family•Food & Drink•Gardening•Health•Other•Pets•Psychology•Spiritual•Travel•Women |
| Calculators |
|