Object Oriented Programming PHP
PHP is also object oriented programming.......
<?php
class abc{
function hkc(){
echo "Hasib Kamal Chowdhury";
}
}
$object = new abc;
echo $object->hkc();
?>
This is very basic example of OOP in PHP.
Here, At first of all we have to create a class. In this code we created a class named 'abc' and in this class we declared a function named 'hkc()'. So, Now the question is how we will call the function hkc() from the class 'abc'. In the next step we have to create an object. $object is something like as variable where we contained the class 'abc'. Procedure shown below how to make object.
$variable = new abc;
This is the procedure to create object. Now we will call hkc() function from $object. The procedure of calling function from object is shown below.
$object->hkc();
<?php
class abc{
function hkc(){
echo "Hasib Kamal Chowdhury";
}
}
$object = new abc;
echo $object->hkc();
?>
This is very basic example of OOP in PHP.
Here, At first of all we have to create a class. In this code we created a class named 'abc' and in this class we declared a function named 'hkc()'. So, Now the question is how we will call the function hkc() from the class 'abc'. In the next step we have to create an object. $object is something like as variable where we contained the class 'abc'. Procedure shown below how to make object.
$variable = new abc;
This is the procedure to create object. Now we will call hkc() function from $object. The procedure of calling function from object is shown below.
$object->hkc();
Comments
Post a Comment