Anda di halaman 1dari 8

UNIT-II

PHP & XML


Prerequisite
Before learning PHP, you must have the basic
knowledge of HTML.
What is PHP
PHP stands for HyperText Preprocessor.
Earlier called as Personal Home Page
PHP is an interpreted language, i.e. there is no need for
compilation.
PHP is a server side scripting language.
PHP is faster than other scripting language e.g. asp and jsp.
PHP supports various databases like MySQL, Oracle, Sybase,
Solid, PostgreSQL, Informix etc.
PHP is an open source software and it is free to download
and use.
PHP is an object-oriented language.
Advantages of PHP
1. Free of Cost: PHP is open source and all its components
are free to use and distribute.
2. Platform independent: PHP is platform independent and
can be run on all major operating systems.
3. Compatible with almost all servers: PHP is compatible
with almost all servers used today.
4. Secure: PHP has multiple layers of security to prevent
threats and other malicious attacks.
5. Easy to learn: PHP has a very easy and understandable
syntax. Its codes are based on C, C++ and embedded with
HTML so it is very easy to learn for a programmer.
6. Embedded: PHP code can be easily embedded within
HTML tags and script.
Install PHP
To install PHP, we will suggest you to install
AMP(Apache,MySQL, PHP) software stack. It is
available for all operating systems. There are many
AMP options available in the market that are given
below:
1. WAMP for Windows
2. LAMP for Linux
3. MAMP for Mac
4. SAMP for Solaris
5. FAMP for FreeBSD
6. XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross
Platform: It includes some other components too such as
FileZilla, OpenSSL, Webalizer, OpenSSL, Mercury Mail etc.
PHP Syntax
A PHP script can be placed anywhere in the
document.
A PHP script starts with <?php and ends with ?>:
<?php
// PHP code goes here
?>
The default file extension for PHP files is ".php".
A PHP file normally contains HTML tags, and
some PHP scripting code
Example
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Output:
My first PHP page
Hello World!
Note: PHP statements end with a semicolon (;).
PHP Echo
PHP echo is a language construct not a function, so you
don't need to use parenthesis with it.
But if you want to use more than one parameters, it is
required to use parenthesis.
he syntax of PHP echo is given below:
void echo ( string $arg1 [, string $... ] )
PHP echo statement can be used to print string, multi
line strings, escaping characters, variable, array etc.
<?php
echo "Hello by PHP echo";
?>

Anda mungkin juga menyukai