
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
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)
Advertisements