![]() |
|
|
||||
|
||||
Here you will learn the basics of PHP, just simple items that relates to everyday scripts.
Comments Tags Using comments in script is very helpful, for anyone else and yourself . Its to help you remember what that part of the script does. Here are three types of comment tags. [php] /* Comments in here */ # Comment per line // Comment per line [/php] The first tag /* */ can cover multiple lines, unlike the other two which only cover one line. Comments in action [php] <? /* ** Comment in testing!!! ** Created by: kambodianboi */ # Generate a random number! $rand = rand(1,20); // Process and loop, at the same time, count to that random number! for($i=0;$i<$rand;$i++) { if($i != $rand-1) { echo $i."<br/>"; } else { echo "Yah! The random number was ".$i; } } ?> [/php] *Summary: All comments made in a script is not processed by the PHP engine only used for author purpose. Handling Errors Here you will learn on how to handle an error, when processing a script. Lucky for PHP it will display an error report, if there was an error in the script. For example: [php] <? if(1=$i) { $action = "go" } ?> [/php] The output will be an error, displaying Code:
Parse error: parse error in <Script Directory> on line 2 [php] if(1=$i) [/php] Now we should work with this part, well to actually fix and error you have to know more actions and functions, but as a basic, varibles $i must always be first to be given a value. Proper way is: [php] if($i=1) [/php] $i is now 1. After you change it to the proper way; Now process the script, it will give you another error. Code:
Parse error: parse error in <Script Path> on line 5 [php] $action = "go" [/php] Something you should know, when a varible is given a value and is not use in the IF phase, it MUST have an end bracket ; Proper way: [php] $action = "go"; [/php] Ok, not change that and process it. Final correct script will look like this. [php] <? if($i=1) { $action = "go"; } ?> [/php] Stay tuned for more tutorials -Kambodianboi *Note: I would make some PHP tutorial videos, but my vocal translation isn't the best.
__________________
Xbox 360 - 2 Games - 2 Controllers - 120GB Elite - Dead PS3 - 23 BD Games - 13 PSN Games - 9 Controllers - 320GB - Alive Wii - 6 Games - 4 Wiimotes - Alive PC - Overkill - God like :] EVO - Needs new clutch & brakes :[ ![]() Gaming Generations | XnogarD Production - Soon!!! |
|
|
|||
|
|||
|
thanks for that
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|