XTREME-SOURCE
Search:

Go Back   XTREME-SOURCE > TUTORIALS > TUTORIAL ARCHIVE > TUTORIALS: WEB DESIGN
Shoutbox
Loading...


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-31-2006, 07:06 AM
kambodianboi's Avatar
Administrator
 
Join Date: Aug 2005
Posts: 3,172
Send a message via AIM to kambodianboi Send a message via Yahoo to kambodianboi
[PHP]Learning the basic

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
Its saying there is an error on line 2, now we go back and check it out. Line 2 has this part of the code
[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
Now on line 5 has:
[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!!!
Reply With Quote
 
Old 05-24-2007, 09:05 PM
XS Enthusiast
 
Join Date: May 2007
Posts: 1

thanks for that
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


vBulletin 3.7.1 ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0