PHP is officially known as PHP: HyperText Preprocessor. It is a server-side scripting language, just like Active Server Pages (Asp), Java Server Pages (Jsp), and Cold Fusion (CF). It is usually written in an HTML context. Unlike an ordinary HTML page, the server doesn’t send a PHP script directly to a client; Instead, it is parsed by the PHP binary or module. HTML in the script is ignored, but PHP code is interpreted and executed. PHP code in a script can query databases, create images, read and write files, communicate with remote servers – the possibilities are endless. Finally the PHP code result and HTML are combined and the output is sent to the client.
PHP installation on your computer In order to run PHP on your computer, you must have the following components installed on it.
1. Web server (IIS or Apache)
3. MySQL (optional)
Most websites advise you to install all components manually, but it’s just a waste of time. Visit and install the latest version of WAMP. With a single click, PHP, Apache and MySQL will be automatically installed on your computer. It is an open source software and very easy to use.
How to run PHP scripts
During installation, WAMP creates a “www” directory in the installation folder. Store all your PHP scripts in it and then call it like this from your browser
” where “yourscriptname” is the name of your PHP file.
Open your favorite text editor. Like HTML documents, PHP files are plain text. You can create them with any text editor like Notepad. However, I advise you to use a specialized PHP editor. Macromedia Dreamweaver is the best PHP editor, but it’s not free. You can find many good PHP editors at http://www.sourceforge.net
or just google “free php editors”
Here is your first PHP script
2: “Hello world!” to press;
Save this script in the www directory. Then call it like this from your browser
You will get the following result;
Remember: Always write your PHP code between opening and closing tags. Consider the following example.
Code goes here
Adding comments to PHP code
A comment is text in a script that is ignored by the interpreter. Comments make your life a lot easier because code that seems clear at the time of writing can be extremely frustrating when you change it six or twelve months later. Adding comments saves time and makes it easier for other programmers to work with your code.
You can comment in many ways
Single-line comments begin with two forward slashes (/ /) or a single hash sign (#).
All text from either of these markers to either the end of the line or the closing PHP tag is ignored.
// This is a comment # This is another comment
Multi-line comments begin with a slash followed by an asterisk (/*) and end with an asterisk followed by a slash (*/).
Add your text here.
The interpreter doesn’t parse it.
Thanks to Ehsen Siraj | #Beginners #Guide #Php