I started to learn PHP and my first program was the well known Hello World. The first line opens the program. The second line is a comment, meaning the computer skips that line, and it is only for me and other users to use. The third line tells the computer to write what is put in between the brackets, '\n' being a return. The fourth line tells the computer to also write what is in the brackets. The last and fifth line ends the program.
<?php //Hello World echo "\nWelcome back Your Awesomeness\n"; echo "How are you?\n\n"; ?>
Fany-Savinas-Mac:PHP Fany$ php hello.php
Welcome back Your Awesomeness
How are you?
I also made another program, entitled Hello User. The first line opens the program. The second line creates a variable. A variable is like an empty box in which information can be put. Only one piece of information can fit at a time. Another way of looking at it, is that a variable is a blank ready to be filled up. On the second line, our variable is $firstname. The next part tells the computer what to place into the variable. I told the computer to place the argument number 1. In PHP, arguments start with 0, meaning argument number 1 is actually in the second position. Argument number 0, in the first position, would be the name of the program. Line three does the same as line two, only with a new variable named $surname and argument number 2, which is in third position. The fourth line tells the computer to write Hello along with the suitable arguments place in the command. Line 5 ends the program.
<?php $firstname=$argv; $surname=$argv; echo "\nHello $firstname $surname \n\n"; ?>
Fany-Savinas-Mac:PHP Fany$ php hello_user.php Fany Savina
Hello Fany Savina