• My PHP Pages

    This is a complete and free PHP programming course for beginners. Everything you need to get started is set out in section one below.

Sep 24, 2013

Posted by Unknown
3 comments | 12:51 AM
you can send emails using PHP. for send emails  we can use mail() php function. look at below example and change variable values to yours. this script is working with gmail too..

$to      = 'yourmail@mail.com';
$subject = 'Your Subject Goes Here';
$message = '



Your Mail Body Goes Here... !
'; $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "CC: php@example.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; mail($to, $subject, $message, $headers); echo '
Sent Successfully !..
';

Read More..

Sep 22, 2013

Posted by Unknown
5 comments | 11:32 PM

                                                      You can use PHP ZIP function to make archives using PHP. I have create a PHP Class to zip all folders and files in a given directory you just need to add source directory and  destination path. Look at the code bellow... Copy bellow code and save it as PHP file name it as 'tozip.class.php'





function Zip($source, $destination)
{
    if (!extension_loaded('zip') || !file_exists($source)) {
        return false;
    }

    $zip = new ZipArchive();
    if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
        return false;
    }

    $source = str_replace('\\', '/', realpath($source));

    if (is_dir($source) === true)
    {
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);

        foreach ($files as $file)
        {
            $file = str_replace('\\', '/', $file);

            // Ignore "." and ".." folders
            if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
                continue;

            $file = realpath($file);

            if (is_dir($file) === true)
            {
                $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
            }
            else if (is_file($file) === true)
            {
                $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
            }
        }
    }
    else if (is_file($source) === true)
    {
        $zip->addFromString(basename($source), file_get_contents($source));
    }

    return $zip->close();
}



Use Bellow Code to execute the function where you need. You need to include 'tozip.class.php' file too


require_once('tozip.class.php');
zip("your_source_path","your_destination_path/your_file_name.zip");


Read More..

Sep 18, 2013

Posted by Unknown
1 comment | 3:05 AM

 For this you basically need two files one is class file and other one is the file that where you calling PDO connection. You can reduce rewriting connection using this OOP PDO script. This class returns after the execution. if connection established successfully it returns '1' else it return error description

 Here is the Class.


dbuser = $dbuser;
 $this->dbpass = $dbpass;
 $this->dbhost = $dbhost;
 $this->dbname = $dbname;
  
       
   }
   function connect()
   {
 try
 {
 $DBH = '';
 $DBH = new PDO("mysql:host=$this->dbhost;dbname=$this->dbname", $this->dbuser, $this->dbpass);
 return 1;
 }
 catch(PDOexception $e)
 {
 return $e->getMessage();
 
 }
 }
}
// how to connect 
//$obj = new db_handler("Username","Password","Host","Database");
//$obj->connect();
?>
Use following code where you need to place connection
connect();
if($db == 1)
{
 echo 'connected';
 }
 else
 {
  echo $db;
  }
?>

Read More..

Jul 10, 2013

Posted by Unknown
2 comments | 11:52 PM

Inserting data into database is the most common operation. Using PDO this is just two step process. in this article lets see how to inset data using PDO 

Bellow is very simple insert code.. lets look at it..



//STH means Statement Handler 
$STH = $DBH->prepare("INSERT INTO my_table VALUES('my php pages')");
$STH->execute(); 



This operation can be done using exec() function also. but it is good to use prepare method because it helps to protect you from sql injections attack. for this protection we have use placeholders. it automatically making data used in the placeholders safe from sql injection attacks.

We can divided Prepare placeholders into three types

  1. No placeholders
  2. Unnamed placeholders
  3. Named placeholders


No placeholders

//STH means Statement Handler 
$STH = $DBH->prepare("INSERT INTO my_table(name,id) VALUES('my php pages',123)");
$STH->execute(); 

Unnamed placeholders

//STH means Statement Handler 
$STH = $DBH->prepare("INSERT INTO my_table(name,id) VALUES(?,?)");
$STH->execute(); 

Named placeholders

//STH means Statement Handler 
$STH = $DBH->prepare("INSERT INTO my_table(name,id) VALUES(:name,:id)");
$STH->execute(); 


Setting data values to Unnamed and Named Placeholders

Lets see how to set data values to Unnamed Placeholder. there is two methods we can use, one is assign values one buy one to variables or assign values to array.


Unnamed Placeholders

Assign values to each placeholder using variable

//Add variable to each placeholder
$SDH->bindParam(1,$name);
$SDH->bindParam(2,$id);

//insert new row
$name = 'my php pages PAGE 1';
$id = 1;
$SDH->execute();

//insert another row with different values
$name = 'my php pages PAGE 2';
$id = 2;
$SDH->execute();

Use an array to set data to placeholder

$data = array('my php pages PAGE 1',1);

$STH = $DBH->prepare("INSERT INTO my_table(name,id) VALUES(?,?)");
$STH->execute($data);



Named Placeholders

Assign values to each placeholder using variable

//Add variable to each placeholder
$SDH->bindParam(':name',$name);
$SDH->bindParam(':id',$id);

//insert new row
$name = 'my php pages PAGE 1';
$id = 1;
$SDH->execute();

//insert another row with different values
$name = 'my php pages PAGE 2';
$id = 2;
$SDH->execute();

Use an array to set data to placeholder

$data = array('name' => 'my php pages PAGE 1', 'id' = > 1);

$STH = $DBH->prepare("INSERT INTO my_table(name,id) VALUES(:name,:id)");
$STH->execute($data);

Read More..

Jul 9, 2013

Posted by Unknown
No comments | 5:16 AM

PDO can use exceptions and handle errors. Every time when you use PDO it is good to use it with in try catch block. there is three error modes available in PDO and you can set the error mode attribute on your database.

Lets look at the code.



$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );  
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );  
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); 


No matter what exception mode you set up it will always return an exception value and it must be inside try catch blocks.

Lets see error modes one by one.


PDO::ERRMODE_SILENT

This is the default error mode. If you leave it in this mode, you’ll have to check for errors in the way you’re probably used to if you used the mysql or mysqli extensions. The other two methods are more ideal for DRY programming.

PDO::ERRMODE_WARNING

This mode will issue a standard PHP warning, and allow the program to continue execution. It’s useful for debugging.

PDO::ERRMODE_EXCEPTION

This is the mode you should want in most situations. It fires an exception, allowing you to handle errors gracefully and hide data that might help someone exploit your system. Here’s an example of taking advantage of exceptions:


setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
  
  // Note : Typed DELECT instead of SELECT syntax  
  $DBH->prepare('DELECT name FROM people');  
}  
catch(PDOException $e) {  
    echo "Error Occurred : ".$e->getMessage();  
}  

Read More..

Jul 5, 2013

Posted by Unknown
4 comments | 7:37 AM

Most of the PHP developers using Mysql or Mysqli php functions when they work with databases. but PHP has introduced new extension call PDO in PHP 5.1. this methord is way better and very productive. PDO is stands for PHP Data Objects. 

Note : Mysql functions is removed from PHP 5.5. so its better to use PDO or Mysqi. I strongly recommend to use PDO.



PDO Supported Databases Drivers List


You can use bellow code to find which driver is installed on your system.
 print_r(PDO::getAvailableDrivers()); 
  1. PDO_DBLIB ( FreeTDS / Microsoft SQL Server / Sybase )
  2. PDO_FIREBIRD ( Firebird/Interbase 6 )
  3. PDO_IBM ( IBM DB2 )
  4. PDO_INFORMIX ( IBM Informix Dynamic Server )
  5. PDO_MYSQL ( MySQL 3.x/4.x/5.x )
  6. PDO_OCI ( Oracle Call Interface )
  7. PDO_ODBC ( ODBC v3 (IBM DB2, unixODBC and win32 ODBC) )
  8. PDO_PGSQL ( PostgreSQL )
  9. PDO_SQLITE ( SQLite 3 and SQLite 2 )
  10. PDO_4D ( 4D )



Lets Connect to the database using PDO


Note :  Different database drivers may have different connection methods. i am not going to all of them i will just explain how to connect with most common databases.








Connect Mysql using PDO_Mysql

$user = "root";
$pass="";
$host="localhost";
$dbname="my_db";
try
{
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
}
catch(PDOexception $e)
{
echo $e->getMassage();
}



Connect Ms Sql Server Using PDO

$user = "root";
$pass="";
$host="localhost";
$dbname="my_db";
try
{
$DBH = new PDO("mssql:host=$host;dbname=$dbname", $user, $pass);
}
catch(PDOexception $e)
{
echo $e->getMassage();
}

Connect Sybase using PDO

$user = "root";
$pass="";
$host="localhost";
$dbname="my_db";
try
{
$DBH = new PDO("mybase:host=$host;dbname=$dbname", $user, $pass);
}
catch(PDOexception $e)
{
echo $e->getMassage();
}

Connect SQLite using PDO

try
{
$DBH = new PDO("sqlite:my/database/path/database.db");  
}
catch(PDOexception $e)
{
echo $e->getMassage();
}

Close PDO Connection

$DBH = null;


Every time you use PDO, use it inside try catch statement. cheers...




Read More..

Jul 2, 2013

Posted by Unknown
1 comment | 9:34 AM

You can easily update and delete data in mysql tables using php. This update & delete functionality is almost same as insert data. just sql query is difference.

Lets look at how to update data. for this you have to use UPDATE sql statement. lets look at the code below.



//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}

//select database
$db=mysql_select_db("my_database",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}
//making sql update query string.
$sql="UPDATE my_table SET name = 'Nimal' WHERE tp_num = 0771239845";

//Execute the mysql query and check is execution process is succeeded
$values = mysql_query($con,$sql);
if(isset($values))
{
echo "Successfully Updated..!";
}
else
{
die('Error Occurred'.mysql_error($con));
}

//close connection
mysql_close($con);

I think above script is not hard to understand  so lets move to the Delete statement. to delete a value we need to use sql DELETE statement. lets roll to the cording part.




//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}

//select database
$db=mysql_select_db("my_database",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}
//making sql delete query string.
$sql="DELETE FROM my_table WHERE tp_num = 0771239845";

//Execute the mysql query and check is execution process is succeeded
$values = mysql_query($con,$sql);
if(isset($values))
{
echo "Successfully Deleted..!";
}
else
{
die('Error Occurred'.mysql_error($con));
}

//close connection
mysql_close($con);

So basically we have covered basic things that you can do using mysql and php. On this tutorials we've been using mysql_xxx functions but PHP has introduce new set of functions like mysqli_xxx and PDO. we will go through those functions here after.Cheers...



Read More..

Jul 1, 2013

Posted by Unknown
No comments | 10:13 AM

Today we gonna talk about how to retrieve data from a mysql database. in last three lessons we learned about how to create a connection to database, how to create database & tables and how to insert data. if you have any problem with those things you better read few last post before go through this. ok lets begin.

In this case we have to use Sql SELECT statement through mysql_query() function to fetch the data from mysql tables. There is several options that you can use to fetch data from mysql.

The most common function to use for this is mysql_fetch_array(). this function can return numeric array or associated array maybe in some cases it can return both types. it will return false if there is no values.

Lets look at the sample code below.


//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}

//select database
$db=mysql_select_db("my_database",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}
//making sql query string. This table has two columns as name and tp_num (telephone number)
$sql="SELECT * FROM my_table";

//Execute the mysql query and check is execution process is succeeded
$values = mysql_query($con,$sql);
if(isset($values))
{


      while($row=mysql_fetch_array($values))
        {

         echo "Name :".$row['name'];
         echo "Contact Number :".$row['tp_num'];
         echo "<hr/>";
         }
 

mysql_free_result($value);

}
else
{
die('Error Occurred'.mysql_error($con));
}

//close connection
mysql_close($con);



We have use mysql_fetch_array() function here. i have sent only one argument to it in my case. but it can handle two paremeter inputs.  mysql_fetch_array(return_value_of_mysql_query(), MYSQL_ASSOC or MYSQL_NUM).. second argument is optional it can be  MYSQL_ASSOC or MYSQL_NUM.

MYSQL_ASSOC - If you used  MYSQL_ASSOC as second argument function will return row as an associated array.

MYSQL_NUM - If you used MYSQL_NUM as second argument it will return row with numeric index.

There is a another function that you can use for fetch data from mysql. that is mysql_fetch_assoc() it's also return row as an associated array.

You can see that at the end of while loop i have used new function call  mysql_free_result(). this function is use to release cursor memory. it is good practice to release memory at the end.

Try to play with codes and try to do this by your own. Cheers.. 





Read More..

Jun 30, 2013

Posted by Unknown
3 comments | 5:55 AM


Today lesson is about how to insert data to mysql table using php mechanisms. In last two lessons we learned about how to make a connection and how to create a database and tables. if you have any problems with those things you better read last posts before go through this.


There is no much different between creating table it is just sql string. Lets look at the code.

//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}

//select database
$db=mysql_select_db("my_database",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}
//making sql query string. This table has two columns as name and telephone number
$sql="INSERT INTO my_table('Rajika Nanayakkara',071999999)";

//Execute the mysql query and check is execution process is succeeded
if(mysql_query($con,$sql))
{
echo "Insert Successfully..! ";
}
else
{
echo "Error occurred while inserting data :".mysql_error($con); 
}

//close connection
mysql_close($con);





Read More..

Jun 29, 2013

Posted by Unknown
No comments | 5:57 AM

In the last lesson we learned about how to make a connection to mysql database. To create either database or table first we need to make a connection to the database server.


Please read last post if you don't know how to create the connection to mysql server.

Creating  a Database

We have to use new method to execute sql queries.
mysql_query(connection,sql query sting)
  • connection- return value of mysql_connect() function
  • Sql query string - sql query that you need to execute

mysql_query() function returns a Boolean value if query execute successfully it will return true value else false value. Lets look at the code


//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}
//making sql query string
$sql="CREATE DATABASE my_database";

//Execute the mysql query and check is execution process is succeeded
if(mysql_query($con,$sql))
{
echo "Database Created..!";
}
else
{
echo "Error occurred while creating database :".mysql_error($con); 
}

//close connection
mysql_close($con);




Creating a table

Difference between creating table and database is just sql query sting value and you have to select database to create table using mysql_select_db() function. lets make simple code..



//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}

//select database
$db=mysql_select_db("my_database",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}
//making sql query string
$sql="CREATE TABLE my_table(name varchar(10),phone int)";

//Execute the mysql query and check is execution process is succeeded
if(mysql_query($con,$sql))
{
echo "Table Created..!";
}
else
{
echo "Error occurred while creating table :".mysql_error($con); 
}

//close connection
mysql_close($con);


Try to make your own database and create some simple tables using it. in next post i will explain how to insert data using php..

Cheers 




Read More..

Jun 28, 2013

Posted by Unknown
No comments | 8:29 AM


Lets connect mysql database using php. there is some special php functions for this..

mysql_connect(host,username,password)

Host - host is optional its host name of mysql database. most of the time its localhost

username - mysql username

password - mysql password


There is a another function to do this.

mysqli_connect(host,username,password,dbname)

Note : it is mysqli_connect()  this is new method php introduced "i" stands for improvements . there is number of improvements in this functions. you can find them in php documentation 


Close mysql connection

mysql_close() or mysqli_close()


Select Database

mysql_select_db(database_name,connection_string);

Database name - Default database to connect with.

Connection string - Connection string is output of  mysql_connect()

Ok now lets make simple connection to mysql database using this two methods...



//make connection
$con = mysql_connect("localhost","root","123");
//check connection
if(!$con)
{
die('Could not connect to the database:'.mysql_error());
}
//select database
$db=mysql_select_db("my_db",$con);
 if(!$db)
{
die('Could not connect to the database:'.mysql_error());

}

//close connection
mysql_close($con);





Read More..

Jun 23, 2013

Posted by Unknown
10 comments | 9:45 AM

Today we gonna talk about how to work with radio buttons using php. a sample radio button image is bellow. Lets create a sample HTML code.




File name : radio.html

<html>
<head>
<title>radio form</title>
</head>

<body>

<form name="radiobtnform" method="post" action="process.php">

<form name="radiobtnform" method="post" action="process.php">
<label>Gender : </label>
<input type="radio" name="gender" value="male"/>Male
<input type="radio" name="gender" value="female"/>Female
<input type="submit" name="sendgender" value="Send"/>
</form>

</send>
</html>

Ok.. now we have done with html file. today i'm going to get form data to separate php file. so as we have talked in previous Form lesson i should set php file name to action attribute value. you can see that i have set action attribute value as process.php.

File name : process.php

<?php

if(isset($_POST['sendgender']))
{
$selected_radio = $_POST['gender'];
echo "You are : ".$selected_radio;
}

?>






Read More..

Jun 21, 2013

Posted by Unknown
3 comments | 9:43 AM


Today we talk about how to work with forms in PHP.. lets make a simple form using HTML



<html>
<head>
<title>my form</title>
</head>
<body>
<form name="myform" action="" method="post">
<lable> Enter Your Name : </lable>
<input type="text" name="name"/>
<input type="submit" name="submit_btn" value="Hit on me !"/>
</form>
<!-- PHP Part begins after this line -->



Note- There is a two very impotent attributes in form tag


  • Action attribute
This action attributes use for set where to send data once form is submitted. if we keep action attribute blank it will send form data to self page or if we use some page name it will send form data to that page.


  • Method attribute
There is two method attribute values that we can use one is 'post' other once is 'get'. both methods are use to send data but they uses different methods. if we use 'post' method it will send data using HTTP port translation or if we use get method it will send data using URL variables



How to catch submitted data using PHP

There is two methods to catch data as well. if we use 'post' method to send data we have to use $_POST array to catch data or if we use 'get' method to send data we have to use $_GET array here.

I used 'post' method before so i will use $_POST array here..

<?php

if(isset($_POST['submit_btn']))
{
$name = $_POST['name'];
echo "Your Name is :". $name;
}
?>

Note : isset() method is use for identify that variable is set and is not null



Completed Code..

<html>
<head>
<title>my form</title>
</head>
<body>
<form name="myform" action="" method="post">
<lable> Enter Your Name : </lable>
<input type="text" name="name"/>
<input type="submit" name="submit_btn" value="Hit on me !"/>
</form>

<!-- PHP Part begins after this line -->
<?php

if(isset($_POST['submit_btn']))
{
$name = $_POST['name'];
echo "Your Name is :". $name;
}
?>
<!-- PHP part ends -->

</body>
</html>

Note : If we use a value for action attribute we have to place the php code in relevent php page that we use as action attribute value. as a example if you set your action attribute value as action="process.php" you have to place your php code inside process.php file..






Read More..

Jun 20, 2013

Posted by Unknown
No comments | 12:04 AM

Today lession is how to work with PHP arrays. An array is a variable which can store number of values at once


<?php
$phones = array("nokia","sony","samsung");

echo "Phones : ".$phone[0].",".$phone[1]." and ".$phone[2];


?>

result - Phones : nokia , sony and samsung


We can count number of values in the array using count() function.


<?php
$phones = array("nokia","sony","samsung");

echo "Phones : ".$phone[0].",".$phone[1]." and ".$phone[2];

echo "<br/> Number of values in this array is : ".count($phones);
?>

result - Phones : nokia , sony and samsung
            Number of values in this array : 3


Lets create an Associative arrays

There is no much difference between associative array and normal array but when we work with normal arrays, we retrieve data using index number. but if we use associative array we can use name keys to retrieve data. 

Lets see how to create an associative array.



<?php

$age = array("kasun"=>50,"nimal"=>55,"dasun"=>57)

echo "kasun is : ".$age['kasun']."years old";
?>



Read More..

Jun 17, 2013

Posted by Unknown
No comments | 4:08 AM
PHP also has if else , while , do while and for statements.
lets see how to write a simple if else statement. i am not going to talk in depth about this statements  since php statements are same as other programming languages


<?php

$today =  date_format(date_create(date("y-m-d")), 'l');

echo "Today is : ".$today."<br>";

if ($today != 'sunday' or $today != 'saturday')
{
  echo "Have a nice day !";
}
else
{
echo "Have a nice weekend !";
}


?>

Please don't mind about data function that i have used. i will explain about data functions later.
you can try to write codes using other statments. if any problem please contact me through email - rajika4ever@gmail.com




Read More..

Jun 14, 2013

Posted by Unknown
1 comment | 8:45 PM



Variables are use for storing values, like string numbers or arrays. when a variable declared, it can be used over and over again in your script.

Note : All Variables in PHP start with a $ sign symbol

example : $my_variable = 100;

-----------------------------------------------------------------------------------------------------------

PHP is loosely typed language 


In PHP, a variable dose not need to be declared before adding a value to it.

<?php
$mytxt = "My PHP Page";
$x = 100;
?>


in the example above, you see that you do not have to tell PHP which data type the variable is, PHP automatically converts the variable to the correct data type , depending on its assigned value.


Naming Rules for variables 


A variable name must start with a letter or an underscore "_" (ex : $_myval or $myval)

A variable name can only contain alpha-numeric characters and underscores ( a-z , A-Z , 0-9 and _ )

A variable name should not contain spaces.


String Variables in PHP

When you store string data in variable , you should use " " marks. ( ex : $mystring = "your name" )


The concatenation operator


The concatenation operator (.) is used to put two string values together.

<?php
$txt1="My Name is : ";
$txt2="Rajika";
echo $txt1.$txt2;
?>

Output : My Name is : Rajika




Read More..

Jun 13, 2013

Posted by Unknown
No comments | 11:34 AM

                                                            Video Tutorial in sinhala
                             For more sinhala video tutorials visit http://myphpvideo.blogspot.com




Comments in PHP

          In PHP we use // to make single line comments and  /* your comment goes here */ to make a large comment block.

example : 

<?php

//This is a single line comment

/*
This is 
a comment
block or in other word
multiline comment 
*/




Read More..

Jun 11, 2013

Posted by Unknown
17 comments | 12:08 PM

                                                   Video Tutorial in sinhala
                             For more sinhala video tutorials visit http://myphpvideo.blogspot.com



How to start coding with PHP

Normally we are writing PHP codes inside HTML so there should be a way to identify HTML and PHP code separately so when we start writing PHP codes always we need to use " <?PHP " at the start and " ?>" mark at the end.

Our first PHP program


<head>
<title>My first php program</title>

<body>

<?php

echo "This is my first PHP program !";

?>

</body>

</head>


Note : echo keyword is using for print..




Read More..

Posted by Unknown
No comments | 11:56 AM

What You Should Already Know

Before you continue you should have a basic understanding of the following:
  • HTML
  • JavaScript
If you want to study these subjects first, find the tutorials on our Home page.

What is PHP?

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a widely-used, open source scripting language
  • PHP scripts are executed on the server
  • PHP is free to download and use
lampPHP is simple for beginners.PHP also offers many advanced features for professional programmers.


What is a PHP File?

  • PHP files can contain text, HTML, JavaScript code, and PHP code
  • PHP code are executed on the server, and the result is returned to the browser as plain HTML
  • PHP files have a default file extension of ".php"

What Can PHP Do?

  • PHP can generate dynamic page content
  • PHP can create, open, read, write, and close files on the server
  • PHP can collect form data
  • PHP can send and receive cookies
  • PHP can add, delete, modify data in your database
  • PHP can restrict users to access some pages on your website
  • PHP can encrypt data
With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.

Why PHP?

  • PHP runs on different platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP has support for a wide range of databases
  • PHP is free. Download it from the official PHP resource: www.php.net
  • PHP is easy to learn and runs efficiently on the server side

Read More..

Posted by Unknown
No comments | 11:48 AM

 PHP: Hypertext Preprocessor

Read More..