
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
Call a Function from a String in PHP
To call a function from a string stored in a variable, use $func.
The syntax is as follows
$func=’anyFunctionName’;
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php function hello(){ echo "Calling hello method."."<br>"; } function welcome(){ echo "Calling welcome method."."<br>"; } $func = 'hello'; $func(); ?> </body> </html>
Output
This will produce the following output
Calling hello method.
Advertisements