
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get current function name in PHP?
To get the current function name in PHP, the code is as follows−
Example
<?php class Base { function display() { echo "\nBase class function declared final!"; var_dump(__FUNCTION__); } function demo() { echo "\nBase class function!"; } } class Derived extends Base { function demo() { echo "\nDerived class function!"; } } $ob = new Base; $ob->demo(); $ob->display(); $ob2 = new Derived; $ob2->demo(); $ob2->display(); ?>
Output
This will produce the following output−
Base class function! Base class function declared final!string(7) "display" Derived class function! Base class function declared final!string(7) "display"
Example
Let us now see another example −
<?php class Base { function display() { echo "\nBase class function declared final!"; var_dump(__FUNCTION__); } function demo() { echo "\nBase class function!"; var_dump(__METHOD__); } } class Derived extends Base { function demo() { echo "\nDerived class function!"; } } $ob = new Base; $ob->demo(); $ob->display(); $ob2 = new Derived; $ob2->demo(); $ob2->display(); ?>
Output
This will produce the following output−
Base class function!string(10) "Base::demo" Base class function declared final!string(7) "display" Derived class function! Base class function declared final!string(7) "display"
- Related Questions & Answers
- How to get current activity name in android?
- How to get current Bluetooth name in android?
- How to get current thread name in android?
- current() function in PHP
- Python How to get function name?
- How to get current country name from Network provider in android?
- How to get the name of the current executable in C#?
- How to get file name from a path in PHP?
- How to get the table name of the current ResultSet using JDBC?
- How to get a variable name as a string in PHP?
- How to print current activity name in android?
- How to print current package name in android?
- How to change current country name in android?
- How to get a function name as a string in Python?
- How to get resource ID using get_resource_id() function in PHP and PHP 8?
Advertisements