Saturday, 15 December 2012

Hello world Program in PHP

Hello world Program in PHP

To get a feel for PHP, first start with simple PHP scripts. Since "Hello, World!" is an essential example, first we will create a friendly little "Hello, World!" script.
A PHP scripting block always starts with . A PHP scripting block can be placed anywhere in the document.

<?php
?>

Below is an example of one of the easiest PHP and HTML page that you can create and still follow web standards.

<body>
<?php
echo "Hello World";
?>
</body>
</html>

The output of this code look like this:

Hello, World!

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".
echo is most widely using print statement in php. You can print variables to use this echo statement. A small example for print variables in php with html code.

<?php
$my_string = "Hello Bob.  My name is: ";
$my_number = 4;
$my_letter = a;
echo $my_string;
echo $my_number;
echo $my_letter;
?>

output

Hello Bob. My name is: 4a

0 comments:

Post a Comment