Taking web design to the next extreme
By Red Squirrel
$_GET and $_POST alone don't contain any value, however, if you add a name at the end, that name can contain a value. For example $_GET[act] contains a value. But $_GET alone does not. $_GET[act2] contains another etc... When a variable has not been assigned a value, it is equal to nothing, it is just empty data, or null. Usually referred as "" when using an if statement and such.
In some more complicated scripts, you want to use more then the $_GET and $_POST. To add a value to your own variable you simply need to go like this:
$variablenume = "value";
Because of the quotes, value is static text, but you can also go like this:
$variablename = $_POST[name];
This would simply give $variablename the same value as $_POST[name], so if you plan to use that often, it saves you from typing the longer one.
You can also combine variables like you can to text with echo:
$variablename = "age: ".$_POST[age];
Variables are not only restricted to text, but also numbers. What's nice about php is that numbers and text mix well and you don't have to worry about converting back and forth. If you have a form with a text field called "a" and a text field called "b" you can do the addition like this:
$answer = $_POST[a]+$_POST[b];
And $answer would be equal to whatever the typed in numbers would add up to. Typing text in this case could lead to unwanted results, but unlike C++, it would not make the script go wild, it would just give 0 in most cases.
There is allot to learn about php because there are many functions that can do cool stuff, but I won't cover it all, however, there's one more thing that may be good to know, and it will be explained on the next page.
This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2017 Ryan Auclair/IceTeks, All rights reserved