get_class_methods

(PHP 4, PHP 5, PHP 7, PHP 8)

get_class_methodsGets the class methods' names

Description

get_class_methods(object|string $object_or_class): array

Gets the class methods names.

Parameters

object_or_class

The class name or an object instance

Return Values

Returns an array of method names defined for the class specified by object_or_class.

Changelog

Version Description
8.0.0 The object_or_class parameter now only accepts objects or valid class names.

Examples

Example #1 get_class_methods() example

<?php

class myclass {
    
// constructor
    
function __construct()
    {
        return(
true);
    }

    
// method 1
    
function myfunc1()
    {
        return(
true);
    }

    
// method 2
    
function myfunc2()
    {
        return(
true);
    }
}

$class_methods get_class_methods('myclass');
// or
$class_methods get_class_methods(new myclass());

foreach (
$class_methods as $method_name) {
    echo 
"$method_name\n";
}

?>

The above example will output:

myclass
myfunc1
myfunc2

See Also

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

PHP cURL Tutorial: Using cURL to Make HTTP Requests

cURL is a powerful PHP extension that allows you to communicate with different servers using various protocols, including HTTP, HTTPS, FTP, and more. ...

TheMax

Autor : TheMax
Category: PHP-Tutorials

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial