By John Koster
The class_basename
function will return the name of the class represented by the provided value.
#Signature
The signature of the class_basename
function is:
1function class_basename(
2 $class
3);
#Example Use
The class_basename
will return the base name of the given $class
. The examples that follow will use the classes defined below:
1<?php
2
3class Object { }
4
5class Person extends Object { }
6
7class Manager extends Person { }
8
9class Executive extends Manager { }
10
11class BoardMember extends Executive { }
12
13$object = new Object;
14$person = new Person;
15$manager = new Manager;
16$executive = new Executive;
17$boardMember = new BoardMember;
The following examples will demonstrate what output is typical of the class_basename
function. The string returned will appear above the function class as a comment.
1// Object
2$baseName = class_basename($object);
3
4// Person
5$baseName = class_basename($person);
6
7// Manager
8$baseName = class_basename($manager);
9
10// Executive
11$baseName = class_basename($executive);
12
13// BoardMember
14$baseName = class_basename($boardMember);
∎