1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What was the first script you created using PHP?

Discussion in 'PHP' started by Gatorade, Jun 16, 2007.

  1. #1
    I'm new to programming but I can gladly say that with a lot of determination I'm starting to learn PHP. At first, I thought that it was something that I just couldn't understand or learn but with a little hard work and good reading it's all starting to click and make sense. It would be nice to see or hear from other PHP programmers, what was your first working script?:)
    SEMrush
     
    Gatorade, Jun 16, 2007 IP
    SEMrush
  2. Nefarious

    Nefarious Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Small scripts to add functionality to other stuff mostly.

    I've only one "real" script that is currently being used on my directory. a pr/link pop type webmaster tool.
     
    Nefarious, Jun 16, 2007 IP
  3. stOx

    stOx Notable Member

    Messages:
    6,426
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    230
    #3
    very first thing was this paper scisors stone game. I had a look around and i still had it.

    <html>
      <head>
        <title>Paper Scissors Stone game </title>
        <meta content="">
        <style></style>
      </head>
      <body>
    <center>
    Select Paper Scissors Stone to play!
    
    <br /><br />
    
    <h1>
    <?php
    
    $player = $_POST["player_select"];
    $computerscore = $_POST["computerscore"];
    $playerscore = $_POST["playerscore"];
    
    if(isset($_POST["player_select"]))
    {
    
    $comprand = rand(1,3);
    
    if ($comprand == 1) { $comp = "<font color=red><b>Paper</b></font>"; }
    if ($comprand == 2) { $comp = "<font color=red><b>Scissors</b></font>"; }
    if ($comprand == 3) { $comp = "<font color=red><b>Stone</b></font>"; }
    
    if ($player == 1) { $selection = "<font color=green><b>Paper</b></font>"; }
    if ($player == 2) { $selection = "<font color=green><b>Scissors</b></font>"; }
    if ($player == 3) { $selection = "<font color=green><b>Stone</b></font>"; }
    
    
    if("$comprand" === "$player")
    {
    echo "computer picked $comp , You selected $selection ---  its a DRAW !<br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>"; 
    }
    else
    {
    
    ////////////////////////////////////
    if($comprand == 1)
    {
    if($player == 2)
    {
    $playerscore = $playerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=green><font color=green><font color=green>YOU WIN !</font></font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    elseif($player == 3)
    {
    $computerscore = $computerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=red><font color=red>YOU LOSE !</font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    ///////////////////////////////////
    }
    
    ////////////////////////////////////
    if($comprand == 2)
    {
    if($player == 3)
    {
    $playerscore = $playerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=green><font color=green><font color=green><font color=green>YOU WIN !</font></font></font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    elseif($player == 1)
    {
    $computerscore = $computerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=red><font color=red>YOU LOSE !</font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    ///////////////////////////////////
    }
    ////////////////////////////////////
    if($comprand == 3)
    {
    if($player == 1)
    {
    $playerscore = $playerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=green><font color=green><font color=green><font color=green>YOU WIN !</font></font></font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    elseif($player == 2)
    {
    $computerscore = $computerscore+1;
    echo "Computer picked $comp , You picked $selection . <font color=red><font color=red><font color=red>YOU LOSE !</font></font></font><br /><br />
    
    Score: Computer: <font color=red>$computerscore</font> ------ You: <font color=green>$playerscore</font>";
    }
    ///////////////////////////////////
    
    
    }
    }
    
    
    
    } // close if(isset($_POST["player_select"])
    
    ////////////////////echo "<br />computer $comprand me $player<br />";
    
    ?>
    </h1>
    <form name="player_select" action="index.php" method="POST">
    <input type="submit" name="player_select" value="1"> Paper<br>
    <input type="submit" name="player_select" value="2"> Scissors<br>
    <input type="submit" name="player_select" value="3"> Stone<br>
    
    <input type="hidden" name="playerscore" value="<?php echo "$playerscore" ?>">
    <input type="hidden" name="computerscore" value="<?php echo "$computerscore" ?>">
    </form>
    </center>
    </body>
    </html>
    PHP:
     
    stOx, Jun 16, 2007 IP
  4. pachecus

    pachecus Well-Known Member

    Messages:
    1,841
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    110
    #4
    The first code of any programmer...
     
    pachecus, Jun 16, 2007 IP
  5. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #5
    i can honestly say i don't even remember my first one. i vaguely recall a guesbook of sorts but i'm not sure. though i can almost guarantee that my first 3 lines consisted of <?php \n echo "hello world"; \n ?> heh
     
    ansi, Jun 16, 2007 IP
  6. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well the first real PHP program was a guestbook that was flat file based. From there I made it MySQL based added features things like that.
     
    InFloW, Jun 16, 2007 IP
  7. dankenpo

    dankenpo Guest

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    A simple form and retrieval file that outputted the user's name (entered in the form) into a new file and said:
    $name = $_POST['name'];
    echo "Hello".$name;
     
    dankenpo, Jun 16, 2007 IP
  8. leede

    leede Guest

    Messages:
    3,381
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    0
    #8
    100% the same as you,

    it is the first one and I will never forget it forever for such PHP "hello" scripts,

    same as Java.:)
     
    leede, Jun 16, 2007 IP
  9. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #9
    Printing 'Hello World' on the screen-this is the first thing in any language.PHP is also a language and I learnt it in a normal.so <?php echo "Hello World"; ?>
    this is was my first script.
    Nefarious,stOX,InFloW-they seem to be so talented-they made those type scripts as their first scripts;they are so genius.I cant believe it :eek:
     
    coderbari, Jun 17, 2007 IP
  10. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I made an e-commerce website with a custom shopping cart integrated into paypal.
     
    klown, Jun 17, 2007 IP
  11. Don2006

    Don2006 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    <?php
    echo "hello world!";
    ?>


    this was my first script :)
     
    Don2006, Jun 17, 2007 IP
  12. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #12
    No idea .....
     
    krakjoe, Jun 17, 2007 IP
  13. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #13
    Mine was probably the simplest..

    <?php
    ?>

    Which output nothing :p
     
    wvccboy, Jun 18, 2007 IP
  14. Lemezo

    Lemezo Active Member

    Messages:
    429
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #14
    The first script I made, was an while trough an array, and echo the text.
     
    Lemezo, Jun 18, 2007 IP
  15. JOGS_DEV

    JOGS_DEV Peon

    Messages:
    136
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #15
    My first PHP code was <?php include('header.htm'); ?> and I didn't even know that I was using PHP script at that moment.
     
    JOGS_DEV, Jun 19, 2007 IP
  16. pfek

    pfek Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #16
    My first php script that's worth something was a login one, using a text file! Quite simple!
     
    pfek, Jun 19, 2007 IP
  17. Crux

    Crux Well-Known Member

    Messages:
    697
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #17
    a form to send email :)

    and didnt do much more

    im not a got programer :)
     
    Crux, Jun 19, 2007 IP
  18. Travis

    Travis Peon

    Messages:
    539
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #18
    The bigger question would be how many of you forgot the semicolon (resulting in a T_STRING error) on your echo"Hello World!"; script? =), I, for one, did haha. Have come a long way however, so all is well.
     
    Travis, Jun 19, 2007 IP
  19. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #19
    probably <?php phpinfo(); ?>
    not sure though as i can't remember it :)
     
    UnrealEd, Jun 19, 2007 IP
  20. NinjaNoodles

    NinjaNoodles Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #20
    I made a contact form, but the first "real" script I made was a weblog.
     
    NinjaNoodles, Jun 19, 2007 IP