Posted The: 03/04/2008 At: 6:47
Last Edited: 06/05/2009 At: 4:08
Contents:
PHP is a serverside programming language, which is used to preprocess data such as:
Note. PHP is not a replacement for html or css, instead it is used togetter, to create "dynamic" websites. It is also used to make calculations, and take decisions if a given condition is met.
You either need your own server such as Apache, with php installed. Or a host which has support for PHP on their server.
I would suggest that beginners simply buy a domainname, and some hosting space, an example of such a host would be one.com.
Most examples will start out with the build-in function called "echo", as will this. Lets start by outputting some text to the browser, using echo.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<!--This is a HTML comment-->
<title>My first Website</title>
</head>
<body>
<?php
echo '<p>My first Website.</p>';
?>
<!--This is a HTML comment-->
</body>
</html>As seen in the above example, we start by telling the server that we are going to write php. Every server which has support for php understand, "<?php" as start tag, and "?>" as end tag. You can also use the echo function to output the whole page, as seen below.
<?php
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<!--This is a HTML comment-->
<title>My first Website</title>
</head>
<body>
<p>My first Website.</p>
<!--This is a HTML comment-->
</body>
</html>';
?>The above isn't really useful, so lets start using php for some useful tasks in the next few tutorials.
Comments: [0]
© Brugbart Webdesign