PHP : Classes

In this tutorial learn how to use object based class in php, Class is a programmer-defined data type, which includes local methods and local variables.

<?php 
   
   class Category
   {
    
    
   }
?>



Tutorial 1 : Create a function in the class using index



class Category
{
    public function index()
    {
      echo "This is object based class.";
    }
}


Create a object to call class and its functions.

$obj = new Category;

echo $obj->index();

Complete Tutorial


<?php
/*
*
*/
// Create a new object
$obj = new Category;

echo $obj->index();

class Category
{
    public function index()
    {
      echo "This is object based class.";
    }
}

?>


No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...