What is PHP?
PHP is a programming language that you can use to write Web applications. A Web application can be anything from a simple “contact us” form through to a fully-fledged blogging system, online store, or forum system.
PHP is a server-side language
What you’ll need
In order to start writing PHP scripts, you need access to a Web server running PHP. Your main options are:
- Run PHP on your own computer: The easiest way to do this is to install a complete package like XAMPP. This contains the Apache Web server, along with PHP and the MySQL database engine, in one easy-to-install package. XAMPP is available for Windows, Mac OS X, and Linux. (A popular alternative on Windows is WampServer.)
- Run your PHP scripts on your Web host: If you already have a Web hosting account that supports PHP then you can upload your PHP scripts via FTP and run them on the Web server. The advantage of this approach is that you don’t have to install anything; the disadvantage is that it’s slower to write and test your scripts.
To create your script, you’ll need to use a text editor program. you can use any editor like notepad, notepad++, sublime text or other.
Write your First PHP Program
</p> <p><?php echo "Hello World"; ?></p> <p>
Note: you need to start and close tag when you write php code. echo use for show your text in the browser. Your browser show your text which you written within in the cotation ” ”
Mix PHP code with HTML
<br /> <!DOCTYPE html><br /> <html><br /> <head><br /> <title>First PHP code with html</title><br /> </head><br /> <body><br /> <?php</p> <p>echo "Hello world.This is my First PHP program code";</p> <p>?><br /> </body><br /> </html><br />
Copy and paste the script code listed above into a new document in your text editor, then save the file as
hello.php in the document root folder — that is, the top level of your website — on your hard drive. If you’re not sure where your document root folder is then consult your Web server manual. Common locations include:
- XAMPP on Windows:
- XAMPP on Linux:
- XAMPP on Mac OS X:
If you want to run the script on your Web hosting account rather than your own computer then you’ll need to upload the script using FTP instead.
Testing the script
Now you’re ready to run your script. To do this, open a Web browser, type the script’s URL into the browser’s address bar, and press Enter. If you’re running the Web server on your own computer then the URL will probably be:
If, on the other hand, you’re running the script on a Web hosting account then you need to use something like:
Good job. You completely learn your first your PHP code setup.