Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design

"Hello <?PHP World ?>"

Let's create a Hello World code in PHP. Gosh I have seen "Hello World" so many times I at times think it's my name. Let's be different. Let's say "Hello PHP World"

<html><head><title>Hello PHP World</title><head>

<body bgcolor="black" text="white">

<?php

  print("<h3>Hello PHP World</h3>");

?>

</body></html>

There are a few things worth noticing:

Ambitious Alternative

You must be feeling ambitious by now. I know I am. So let's make our program do a little more than just "Hello World"-ing the PHP world. Let's say "Hello PHP World", output a "<HR>" and a line saying "PHP seems like fun" in red and a size of 4. In "plain HTML" this would be printed thus:

<h2>Hello PHP World

<hr>

<p><font size="4" color="red">PHP seems like fun</font>

In PHP there is a right solution and a wrong solution. Here is the wrong solution:

<html><head><title>Hello PHP World</title></head>

<body>

<?php

     print("<h2>Hello PHP World");

     echo("<hr>");

     print("<p><font size="3" color="red">PHP seems like fun</font></p>");

?>

</body></html>

What! This is wrong!? Perl and Java(Script) programmers must be smiling by now. The other like you (oops! Sorry) are just buffled. Let's take a refresher.

In point number e) of the points (observations) made earlier we said the text being output should be put WITHIN double quotes. Look at line 6 in our code. How many double quotes do you see? Well. The PHP preprocessor would be as confused as you if you gave it the above code to munch :-O.

How about that echo thingie on line 5. Well. That's fine. There are more than one ways of killing a rat: dip it in hot water, chock it with a blanket, smash it with a slipper, shoot with a canon...

In the same way, there are several ways of outputing text, print() just happens to be one of them and echo() is one of the other sisters.

 

PHP ecommerce web developer India flash website designer India seo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81