Low cost ecommerce web development India flash website design

Basic Syntax and Commands

PHP syntax will be very familiar to anyone with an understanding of C, C++,

Java, JavaScript, Perl, or any other C-derived language. A PHP script consists of

a series of commands, or statements, each of which is an instruction that the

Web server must follow before it can proceed to the next. PHP statements, like

those in the above-mentioned languages, are always terminated by a semicolon

(;).

This is a typical PHP statement:

echo( "This is a <b>test</b>!" );

This statement invokes a built-in function called echo and passes it a string of

text: This is a <b>test</b>! Built-in functions can be thought of as things

that PHP knows how to do without us having to spell out the details. PHP has

a lot of built-in functions that let us do everything from sending email, to working

with information that's stored in various types of databases. The echo function,

however, simply takes the text that it's given, and places it into the HTML code

of the page at the current location. Consider the following (echo.php in the code

package):

<html>

<head>

<title> Simple PHP Example </title>

</head>

<body>

<p><?php echo('This is a <b>test</b>!'); ?></p>

</body>

</html>

If you paste this code into a file called echo.php and place it on your Web server,

a browser that views the page will see this:

51

Basic Syntax and Commands

<html>

<head>

<title> Simple PHP Example </title>

</head>

<body>

<p>This is a <b>test</b>!</p>

</body>

</html>

Notice that the string of text contained HTML tags (<b> and </b>), which is

perfectly acceptable.

You may wonder why we need to surround the string of text with both parentheses

(()) and single quotes (''). Quotes are used to mark the beginning and end of

strings of text in PHP, so their presence is fully justified. The parentheses serve

a dual purpose. First, they indicate that echo is a function that you want to call.

Second, they mark the beginning and end of a list of parameters that you wish

to provide, in order to tell the function what to do. In the case of the echo

function, you need only provide the string of text that you want to appear on

the page. Later on, we'll look at functions that take more than one parameter,

and we'll separate those parameters with commas. We'll also consider functions

that take no parameters at all, for which we'll still need the parentheses, though

we won't type anything between them.

website designer freelance ASP PHP ecommerce web developer
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110