HomeMenu
Bible PicturesGoogle
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

method_exists

Description

The method_exists of Class / Object for PHP checks if the class method exists.

Syntax

method_exists ( mixed $object , string $method_name ) : bool

Parameters

object

An object instance or a class name

method_name

The method name

Return

Returns TRUE if the method given by method_name has been defined for the given object, FALSE otherwise.

Examples

1

<?

class myclass
{
    function myfunction()
    {
    }
}

$object = new myclass();
$method_name = "myfunction";

$return = method_exists($object, $method_name);

var_export($return);
day
d: 20
D: Fri
j: 20
l: Friday
N: 5
S: th
w: 5
z: 323

week
W: 47

month
F: November
m: 11
M: Nov
n: 11
t: 30

year
L: 0
o: 2026
y: 26
Y: 2026

time
a: pm
A: PM
B: 911
g: 8
G: 20
h: 08
H: 20
i: 53
s: 10
u: 000000
v: 000

timezone
e: UTC
I: 0
O: +0000
P: +00:00
T: UTC
Z: 0

full
c: 2026-11-20T20:53:10+00:00
r: Fri, 20 Nov 2026 20:53:10 +0000
U: 1795207990

2

<?

class myclass
{
    function myfunction()
    {
    }
}

$object = "myclass";
$method_name = "myfunction";

$return = method_exists($object, $method_name);

var_export($return);
day
d: 20
D: Fri
j: 20
l: Friday
N: 5
S: th
w: 5
z: 323

week
W: 47

month
F: November
m: 11
M: Nov
n: 11
t: 30

year
L: 0
o: 2026
y: 26
Y: 2026

time
a: pm
A: PM
B: 911
g: 8
G: 20
h: 08
H: 20
i: 53
s: 11
u: 000000
v: 000

timezone
e: UTC
I: 0
O: +0000
P: +00:00
T: UTC
Z: 0

full
c: 2026-11-20T20:53:11+00:00
r: Fri, 20 Nov 2026 20:53:11 +0000
U: 1795207991