Created
September 10, 2019 11:39
-
-
Save msisaifu/bac46f83e3fd6c413af835c4fe6faa2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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