Computers

Basics of a server-side scripting language : PHP (part 1)

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)


<?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.

<?php
print “Hello TuteBox
!”;
?>

Well, both ways do the same job. It is your choice, after all. I mostly use to echo out.


Using variables
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:
<?php
$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?!


Minor calculations
<?php
$val1=3;
$val2=5;

//(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

Share this post

Related Posts

12 thoughts on “Basics of a server-side scripting language : PHP (part 1)”

  1. goldlvl 40 says:

    I truly loved this brilliant article. Please continue this awesome work. Regards, Duyq.

  2. ftp says:

    This is a nice blog i must say, usually i don’t post comments on others’ blogs but would like to say that this post really forced me to do so!

  3. Buy Generic says:

    Great post, I Just wanted to comment that i am not able to connect to your rss stream, you defintely should install a wordpress plugin for that to workthat.

  4. Kala Kipka says:

    I’m bookmarking your site and I’ll be back. Thanks again!

  5. Anthony Rousell says:

    Very informative post, love the best way you write and I believe that the knowledge helps in a way. I do not normally say this, but I feel this is a great job done. For those who wish to alternate links, I might be very happy to supply a link again to your site. Hope to hear from you soon. Cheers

  6. Johnson Krumroy says:

    Wherever can it be, i want to read much more about this posting, thank you.

  7. seems like you guys have already added this feature !

    1. Ruzeen says:

      TuteBox.com is a PHP site anyway.

  8. Marcelino Siebert says:

    Great Post. Thanks for sharing!!

  9. Tumpkin says:

    I just twitted your post to my followers. You made a really good post. Thanks!

Comments are closed.