introduction to PHP

introduction to PHP

introduction to PHP

introduction to PHP

introduction to PHP
introduction to PHP




Hypertext Preprocessor (PHP)

PHP is a server-side, HTML-embedded scripting language that may be used to create dynamic Web pages. It is available for most operating systems and Web servers, and can access most common databases, including MySQL. PHP may be run as a separate program or compiled as a module for use with a Web server.

Syntax:


<?php
……….
………………
?>
 

PHP Syntax: PHP can be written within HTML code in a HTML page, just like JavaScript & other Scripting language. Html can also be written inside the PHP section of your page, which allows you to format text by keeping blocks of code together. PHP can also be written as standalone program with no html at all-
 

  •  PHP is denoted in the page with opening & closing tag as follows-

 

<?php
Code..
?>

 

  •  PHP lines end with a semicolon (;).
  •  // used for single line comment
  • /* used for multi-line comment */
  •  The PHP function "echo‟ is used to send text to the browser.



Example:


<html>
<head>
<title>Demo </title>
</head>
<body>
<?php
echo"my first prograame";
?>
</body>
</html>

 


echo Function:

The echo function tells the processor to output data.
 

Example:


<?php echo '<p>Ram is a good boy.</p>'; ?>


You can use either a single quote (') or a double quote ("). If the text you are printing already has single or double quotes in it, use the other type of quote to surround it.
 

For example:


<?php echo "<p>Ram is a good boy.</p>"; ?>