scenario:
suppose i had a class named category.class.php
1st method:
Code: Select all
<?php
class category
{
// without creating properties
function insertNew($catName,$catDesc,....)
{
//insert into database goes here...
}
}
?>Code: Select all
<?php
class category
{
// with creating properties
var $catName;
var $catDesc;
var ....;
function insertNew()
{
//insert into database goes here...
}
}
?>Code: Select all
<?php
class category
{
var $catName;
var $catDesc;
var ....;
//creating constructor
function category($catName,$catDesc,..)
{
$this->catName = $catName;
$this->catDesc = $catDesc;
.......
}
function insertNew()
{
//insert into database goes here...
}
}
?>1st method:
Code: Select all
<?php
include "category.class.php";
//get the parameters from the user inputs
//creating object
$catOBJ = new category();
$catOBJ->insertNew($catName,$catDesc,....);
?>Code: Select all
<?php
include "category.class.php";
//get the parameters from the user inputs
//without creating obj
category::insertNew($catName,$catDesc,....);
?>Code: Select all
<?php
include "category.class.php";
//get the parameters from the user inputs
$catOBJ = new category($catName,$catDesc,....);
$catOBJ->insertNew();
?>method of applying the OOP method for sake of clarity..
Thanks in advance to all of you !!!!!!!!!!!!!!!!