<?php class social_button { private function social_facebook() { return 'Facebook'; } private function social_instagram() { return 'Instagram'; } private function social_twitter() { return 'Twitter'; } public function all() { $reflection = new \ReflectionObject($this); $prefix = 'social_'; $methods = array_filter($reflection->getMethods(), function (\ReflectionMethod $method) use ($prefix) { return 0 === strpos($method->getName(), $prefix); }); $results = array_map(function (\ReflectionMethod $method) { $name = $method->getName(); return $this->$name(); }, $methods); return $results; } } $button = new social_button(); var_dump($button->all());
You have javascript disabled. You will not be able to edit any code.