- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Passing static methods as arguments in PHP
The same syntax used by is_callable and call_user_func can be used to pass static methods as arguments in PHP.
To pass the static method, the below example can be used −
Example
<?php function my_func() { echo "Hello there!"; } $variable_name = "my_func"; var_dump(is_callable($variable_name, false, $callable_name)); echo $callable_name, "n"; var_dump(is_callable($variable_name)); ?>
Output
This will produce the following output −
bool(true) my_func bool(true)
- Related Articles
- PHP Static Properties and Methods
- Passing Arguments to a Subroutine in Perl
- Static methods vs Instance methods in Java
- Passing arguments to a Tkinter button command
- Passing arrays to methods in C#?
- Static methods in JavaScript classes?
- PHP Function arguments
- Named Arguments in PHP 8
- Shadowing of static methods in Java
- Are static methods inherited in Java?
- Java 8 static methods in interfaces
- Passing unknown number of arguments to a function in Javascript
- PHP Passing by Reference
- Kotlin static methods and variables
- Can interfaces have Static methods in Java?

Advertisements