3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CI_Controller { public function __construct() { } public function post($wl) { $data = []; foreach (array_keys($wl) as $f) { $data[$f] = $_POST[$f] ?? null; } return $data; } } class Search extends CI_Controller { public object $SearchModel; public function __construct() { parent::__construct(); $this->SearchModel = new Search_model(); $whitelist = get_object_vars($this->SearchModel); // var_export($whitelist); foreach ($this->post($whitelist) as $prop => $val) { $this->SearchModel->$prop = $val; } } public function test() { $this->SearchModel->searchByCategory(); } } class CI_Model { public function __construct() { } } class Search_model extends CI_Model { public ?int $productId = null; public ?string $productName = null; public ?string $category = null; public ?string $datetime = null; public ?int $userId = null; public function __construct() { parent::__construct(); //$this->load->database(); } public function searchByCategory() { var_dump(get_object_vars($this)); /* return $this->db->get_where('products', ['category' => $this->category])->result(); */ } } $_POST = ['productId' => '8', 'category' => 'foo']; (new Search())->test();
Output for git.master_jit, git.master
array(5) { ["productId"]=> int(8) ["productName"]=> NULL ["category"]=> string(3) "foo" ["datetime"]=> NULL ["userId"]=> NULL }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
246.43 ms | 723 KiB | 4 Q