What does PHP stand for?
PHP is known as Hypertext Preprocessor these days, but stood as personal home page way back in 1994/95 and 6 (glad it changed to a better-sounding name). Anyway… who cares about the history, unless u really do. Yeah! Google that :]
What is PHP used for?
PHP is used for web development; to produce dynamic web pages. And it wont function as a client-side script. It needs to run on a web server, for it to work. Youʹll understand better as you read the tutorial below.
As you may have heard, there is quite a number of server-side scripting languages such as: ASP, ColdFusion, Ruby, Python, Perl and few others as well. However my favorite for now is PHP, it is simple and user-friendly I think… Lets get started.
Open a text editor of your choice. And start typing (whatʹs in bold), then you can save it as a .php file, upload it to a server and test it yourself. I would recommend http://000webhost.com
<?php //(the opening tag for PHP)
//(here comes all your PHP coding) – any PHP code before/after these tags wont count.
?> //(the closing tag for PHP)
echo “Hello TuteBox!”;
OR you can also write this way: <?php echo “Hello TuteBox!”; ?> the top method is much cleaner and a professional way of coding. There is another alternative to echoing out; printing the message on the screen.
print “Hello TuteBox!”;
Well, both ways do the same job. It is your choice, after all. I mostly use to echo out.
We use variables with the main intention of executing them whenever we want to and to make programming less complicated. Variables are really helpful in any scripting language. In PHP a variable always starts with a dollar sign ($). For example:
$my_pet = “Louise”;
echo “My cat is $my_pet. I adore her a lot.”; //(you also can use print instead of echo)
The result would be: My cat is Louise. I adore her a lot.
If you are a basic web developer, now you must be thinking… so why cant I just type that out. You can! But it is easier for you to manage/update information quickly, especially a large amount of info. If you want to change the name of your cat you just have to change Louise to something else, from $my_pet = “Louise”; how easy is that?!
//(you necessarily need not use quotes for numbers)
$answer = $val1 + $val2;
echo “$val1 plus $val2 equals $answer”;
The result would be: 3 plus 5 equals 8
Fine, lets wind up. Trust me, PHP is very easy to learn and interesting too. If you know the basics you surely can catch-up/understand any PHP code. However, if you really want to know more or get anything clarified just leave a comment below and we will get back to you as soon as possible. Good luck!
Go to PART 2
– thanks for your comments