Skip to content

Instantly share code, notes, and snippets.

@msisaifu
Created September 10, 2019 11:39
Show Gist options
  • Save msisaifu/bac46f83e3fd6c413af835c4fe6faa2a to your computer and use it in GitHub Desktop.
Save msisaifu/bac46f83e3fd6c413af835c4fe6faa2a to your computer and use it in GitHub Desktop.
<?php
class Crud {
public $person = [];
function create($name){
array_push($this->person, $name);
}
function read($id){
echo "index number: {$id} {$this->person[$id]}";
}
function update($id, $name){
$this->person[$id] = $name;
}
function delete($id){
unset($this->person[$id]);
}
function getPerson(){
var_dump($this->person);
}
}
$person = new Crud;
$person->create("zarif");
$person->create("saiful");
$person->create("smith");
$person->create("John");
//$person->getPerson();
$person->read(0);
$person->update(2, "doe");
$person->getPerson();
$person->delete(0);
$person->getPerson();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment