Ways to write PHP scripts

PHP is a server scripting language used to make web pages interactive,dynamic. For example, think of what happens when you edit a page on this website. Behind this process are many, perhaps hundreds, of PHP scripts controlling how web pages change based on a variety of circumstances.This article will teach you how to write a few very simple PHP scripts so that you can get a basic understanding of how PHP works.Many CMS (content manage system) use PHP language that makes web developement so easy.If you want to write php scripts at first you have to install the PHP engine on your computer(Xampp,wamp,memp etc.).

.Method 1:Echo

a)Open Notepad. (File>>All Programs>>Accessories>>Notepad).

b)Then type   (<?php echo “Hello World!”; ?>)c)Save this file as whatever name you want.

.When saving files in Windows Notepad, wrap the filename in double quotations so that Notepad doesn’t add .txt to the end of the filename. Notice in the image that the file hello world.php has ” ” around it. Without the quotation marks Notepad would have saved the file as hello world.php.txt

d)Alternatively, you can simply click the drop down menu under Save as type and change it to “All Files (*.*)” which will leave the name exactly how you type it and the quotes will not be needed.

  • If you receive an error message, make sure you typed the code correctly as shown above, including the colon.
    5101 7b1.jpg
  • This is what you should see in your browser window:

    Hello World!

    5101 7b2.jpg
e)Open your favorite browser. Type this address in the address bar: http://localhost/hello world.php

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s