Ok lets start learning PHP

lionsIT

Member
Mar 26, 2008
23
0
0
Colombo
From today onwards I will post small php tutorials for all you IT lovers :D

if you don't know about php please go to w3schools its the best place to learn.

Today I will show you how to revearse a string without using inbuilt php functions.

try alone before looking at he code.

PHP:
<?php

$my_string = "make this reverse";
$i = 0;
$output ="";
while($c = $my_string[$i]) // you can accesses each character this way
{
    $output = $c.$output; //concatinate $c infront of $output
    $i++;
}

echo $output; //esrever siht ekam
?>

:D
 

TΞΞNSTAR™

Member
Mar 19, 2008
15,866
42
0
StuCk In My AnGelZ HeArT!!!
aha gud work ... but u got to start frm WHATS PHP .. coz sum dnt knw wats PHP na...

PHP is a powerful server-side scripting language for creating dynamic and interactive websites.
PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP is perfectly suited for Web development and can be embedded directly into the HTML code.
The PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server) on various operating systems. It also supports ISAPI and can be used with Microsoft's IIS on Windows.
 

Malinga

Well-known member
  • Jul 20, 2006
    61,301
    1,013
    113
    honda vadak. habai meeka kattiyata therum ganna puluvan aakarayata mula indala ma kalaanum thamai honda. eeta vada PHP virtual host karana vidiyath e magin oya liyana code vala output eka koi aakara venava da kiyana ekath balaganna hati kiyala deela ma karanavanum thamai honda.
     

    lionsIT

    Member
    Mar 26, 2008
    23
    0
    0
    Colombo
    hey guys but there are lot of places where the basics have been done for example w3schools, so is it worth it if I go from the basics? please tell your opinoins
     

    lionsIT

    Member
    Mar 26, 2008
    23
    0
    0
    Colombo
    Ok Lets start php from the basics.

    What is php?
    php is a server side scripting language.

    Why php?
    Free and open source
    easy to understand and develope
    Great support for mysql(database)
    Lot of ready made codes in the Internet

    Even the elakiri.com forum is developed using php

    Why serverside scripts?
    let say that you want to create a login page. you cannot create a login page just using HTML, you need some language(code) to check values entered in the username and password textboxes with the actual values that are stored in the database.
    So now you understand that, to do dynamics things in a website you need serverside script language.

    OK then enough of theory lets start practicals :lol:

    You need a web server to run your php scripts. Apache is a good choice for a webserver(Free).

    Download and install wamp server 2, it's a package of apache + php 5 + mysql
    this is a simple setup just run it.
    http://www.wampserver.com/en/download.php

    ok now your set to run your first php program.
    open a note pad and enter the code below. save it as hello.php (remeber to select All file in the Save as type: box)

    save the file in C:\wamp\www
    www - is the root directory of your apache webserver

    PHP:
    <php
    
    //This is a comment, these will not be printed, comments are used to describe code
    
    echo "Hello ElaKiri"; //echo will display text in your browser
    
    ?>

    You will need to stop IIS in your machine if IIS is installed
    goto start-> run -> and type NET STOP IISADMIN

    Always remeber to start Wamp server before running a php script.
    goto start -> programs -> wampserver -> start wamp server
    wait until the wamp icon in the icon tray(where your computer time is) turn white.

    Open your firefox/ internet explorer and type
    Code:
    http://localhost/hello.php

    Now you should see a Hello ElaKiri in your browser window.

    localhost - it means your computer

    thats it you are on your way to become a php Guru :lol:
     
    Last edited:

    Malinga

    Well-known member
  • Jul 20, 2006
    61,301
    1,013
    113
    oya thiyenne daala hondata. ooka hondai :D wamp valata amatharava Easy Php ekenuth oya kattyuththama karathahaki :D
     

    ravicplk

    Member
    Oct 18, 2007
    4,120
    1
    0
    39
    Sri Lanka
    lionsIT said:
    hey guys but there are lot of places where the basics have been done for example w3schools, so is it worth it if I go from the basics? please tell your opinoins
    this is what expert ayya and discuss about......u are the first one to start a thread
    thank u for that..please start with basicssssssssss..
    we are always with u ..so dont stop ok
     

    lionsIT

    Member
    Mar 26, 2008
    23
    0
    0
    Colombo
    IIS - Internet Information Services
    Its a web server that comes with windows xp (its a optional install so most probally you may not have IIS)

    you can check if its installed by going to
    start -> settings -> control panel -> Administartive Tools
    if you see Internet Information Services icon that means its installed
     

    ravicplk

    Member
    Oct 18, 2007
    4,120
    1
    0
    39
    Sri Lanka
    lionsIT said:
    IIS - Internet Information Services
    Its a web server that comes with windows xp (its a optional install so most probally you may not have IIS)

    you can check if its installed by going to
    start -> settings -> control panel -> Administartive Tools
    if you see Internet Information Services icon that means its installed
    thx:D
     

    lionsIT

    Member
    Mar 26, 2008
    23
    0
    0
    Colombo
    Hey Guys Lets learn about variables.

    just think variable as a box that contain a value. lets see a example

    PHP:
    <?php
    
    $my_variable = "elakir"; //you must use $ infront of your varaible name
    
    /* This is another way of commenting, multilines */
    
    /*
    Now value elakiri is stored in your $my_variable
    Now let see how to print out a variable
    */
    
    echo $my_variable; //This will output elakiri
     echo '<br>'; // to get a newline, any html tags can be displayed this way
    
    //What if I do this
    echo " $my_variable"; //yes it will print as it is, hope you got the idea
    
    ?>
    Ok then, lets learn data types in php

    PHP:
    <?php
    $my_string = "This is a String"; //Strings must be placed between double quotes
    $my_int = 10; //if you want to store numbers, remeber not to use qoutes
    $my_bool = TRUE; //use this way if you want to store only TRUE/FALSE (1/0)
    
    
    echo $my_string;
    echo '<br>';
    echo $my_int;
    echo '<br>'; 
    echo $my_bool; // this will print 1 bcos true, if false then 0
    
    
    ?>
    Ok then thats it for today
    please visit http://www.w3schools.com/php/php_variables.asp
    for more nice tutorials
     
    Last edited: