Object oriented php class simple example

Create a sample oops process from core php

Example:

<?php

class Example_Name

{

  public $name;

  public function show_name()

  {

    return($this->name);

  }

  public function enter_name($Test_Name)

  {

    $this->name = $Test_Name;

  // create a sample database querys from this method;

    

  }

}

?>


checking .php (sample page)

<?php

  include_once("name_class.php");

  $name = $_POST['name'];  //input tag name

  $my_name = new Name();

  $my_name->enter_Name($name); //save to database functions

  $name=$my_name->show_Name(); //call to database function

?>

This way you can achieve this, this is just an overview from createing objects process in php

Sign In or Register to comment.