Lost Password?


  #1 (permalink)  
Old 02-20-2007, 04:33 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default The beginning!

Well if you decided to start learning php then you should view this tutorial. Here i will tell you everything what you need to know for the beginning. Okay let's start.

Syntax

PHP Code:
<?php //Starts your php script also you can just use <?

?> // Ends your php script
How to say Yo Wuzzzupp
PHP Code:
<?php
echo "Yo Wuzzzupp";
?>
(This will print your text: Yo Wuzzzupp)

Comments
PHP Code:
<?php
/* This is
a comment block */

// This is a comment

# This is also a comment
?>
Variables

PHP Code:
<?php
$myVar 
"Hello"// This is a variable
echo $myVar// This will print your variable value
?>
(This will print your text: Hello)

If you want to concatenate two or more variables together, use the dot (.) operator
PHP Code:
<?php
$myVar 
"Hello";
$myVar2 "Jaan!";
echo 
$myVar" ".$myVar2;
?>
(This will print your text: Hello Jaan!)

If...Else Statements

Syntax
Quote:
if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
PHP Code:
<?php
$myVar 
"Jaan";
if(
$myVar=="Jaan"){ // If your variable matches that value (Jaan) then Hello Jaan will be shown
    
echo "Hello Jaan";
}else{ 
// If that value in your variable is not Jaan then "Hello quest" will be shown
    
echo "Hello guest!";
}
?>
(This will print your text: Hello Jaan)

PHP Code:
<?php
$day 
date("D");
if(
$day=="Mon"){ // If today is a monday "Have a nice monday!" will be shown
    
echo "Have a nice monday!";
}else{
    echo 
"Have a nice week!"// If today is not monday then "Have a nice week!" will be shown
}
?>
Arrays

PHP Code:
<?php
$name 
= array("Jaan""Thomas""Mike");
?>
In this example we assign the ID key manually:
PHP Code:
<?php
$name
['0'] = "Jaan";
$name['1'] = "Thomas";
$name['2'] = "Mike";
echo 
"My name is ".$name['0']. ", my friends name is ".$name['1']." and his friends name is ".$name['2'];
?>
(This will print your text: My name is Jaan, my friends name is Thomas and his friends name is Mike)

Looping

Syntax
Quote:
while (condition)
code to be executed;
PHP Code:
<?php
$i 
1;
while(
$i <=5){ // This will repeats your $i value 5 times
    
echo "This number is ".$i."<br>";
    
$i++;
}
?>
Functions

PHP Code:
<?php
function myFunc(){ // This will define your function name
    
echo "My name is Jaan"// Inside of { and } you can put everything that you want
}
echo 
myFunc(); // This will print your funtion
?>
(This will print your text: My name is Jaan)

I hope it helped. Have fun!
__________________


Cheap & Professional Web Design | Need help? Send a PM

Last edited by Jaan; 02-21-2007 at 11:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 02-20-2007, 08:43 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

very nice
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Good Beginning Graphics Resources? AutumnNight General Programming 1 08-25-2007 02:46 AM
Help beginning a programming career spaivxx General Programming 3 08-20-2007 07:49 AM
A great find: Beginning Perl techni68 Perl 0 01-21-2007 06:39 AM


All times are GMT -5. The time now is 05:15 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads