Hello friends, welcome to series tutorial on PHP. From today we are going to start new series on PHP and I hope after completing this series you will able to develop a complete web application using PHP. Today we are learn some quick notes about PHP.
Up until recently, scripting on the internet was something which very few people even attempted, let alone mastered. Recently though, more and more people have been building their own websites and scripting languages have become more important. Because of this, scripting languages are becoming easier to learn and PHP is one of the easiest and most powerful yet. Also there are lot of free and open source PHP CMS available in internet like Joomla, WordPress for create blog website and PHPBB,Vbuletin for forum website are mostly common. All of them very easy to setup and important thing is that they are using PHP as development language. Before using those CMS, if you have some basic knowledge about PHP then it will be great for you to make any change on them according to your choice. So. Let’s go for the basic about PHP and day by day we will learn more details about PHP.
What Is PHP?
PHP stands for Hypertext Pre Processor and is a server-side language. This means that the script is run on your web server, not on the user’s browser, so you do not need to worry about compatibility issues.
PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becoming one of the most popular scripting languages on the internet.
You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website.
Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.
Using scripts on your website allows you to add many new ‘interactive’ features like feedback forms, guestbooks, message boards, hit counters and even more advanced features like portal systems, content management, advertising managers etc.
With these sort of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.
What Do I Need?
As mentioned earlier, PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don’t know if it is installed you can find out using the first script in this tutorial.
If you server does not support PHP you can ask your web host to install it for you as it is free to download and install. If you need a low cost web host which supports PHP.
Writing Your First PHP Code:
Writing PHP on your computer is actually very simple. You don’t need any special software, except for a text editor (like Notepad/Netbeans in Windows). Run this and you are ready to write your first PHP script.
Declaring PHP tags:
PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:
All of these work in exactly the same way but in this tutorial I will be using the first option (). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can’t start with for example).
The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:
As you can see this actually just one line of code. It is a standard PHP function called phpinfo() which will tell the server to print out a standard table of information giving you information on the setup of the server.
Finishing and Testing Your Script:
Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server.
If your script doesn’t work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed,
you are prompted to download the file, PHP is not installed on your server and you should either search for a new web host or ask your current host to install PHP.
Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!