Thursday, 3 November 2016

Database Connection in PHP | How to create connection in php with database

Database Connection in PHP


Php support many types of database like SQL,MySQL,Oracle and other Microsoft database such as ODBC etc.

To create a connection to database with the help of PHP.You must have a server installed locally or remotely.If you buy web hosting on the internet you must know the database host name and password to connect to the database you created on that server.

Or if you don't have such type hosting you can make your computer as a server for this you have to install the server on your local computer.

To know how to make your Computer as server Please Follow the Link below:


Sunday, 23 October 2016

Class in PHP | How create classes in PHP

Classes in PHP

Php Classes.Classes in Php is a new concept like C++.It covers the OOPs concept in PHP.OOPs stands for Object Oriented Programming.you can create classes in PHP like c++ with functions.

To do this:

<?php
class abc
{
function add1()
{
$a=10;
$b=20;
$c=$a+$b;
echo $c;
}
}
$obj=new abc;
$obj->add1();
?>

In the above PHP class example, we create a class with name "abc" also create function name "add1"
we declare two variable a and b and assign them value.Add them and assign the result to another variable c and show the result with echo command.

After this, we create an object of the class and call the function using that object. 

We can add multiple classes and functions in PHP.

<?php
class abc
{
function add1()
{
$a=10;
$b=20;
$c=$a+$b;
echo $c;
}
function mul()
{
$a=10;
$b=20;
$c=$a*$b;
echo $c;
}
}
$obj=new abc;
$obj->add1();
echo "</br>";
$obj->mul();

?>

PHP Class



Php Class
Php Class