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?
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.
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:
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
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.
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;
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.
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
My first PHP code was <?php include('header.htm'); ?> and I didn't even know that I was using PHP script at that moment.
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.