Hi is this possible to call a function within a php file as i wish to call a function within the wordpres function.php file from the command prompt some thing like > php function.php hello2 can this be done ? eg function.php = function hello1 () { echo 'hello'; } function hello2 () { echo 'hello'; }
can you be a bit more elaborate on what you're trying to achieve? why would you want to call a PHP function from command prompt?
To the question as i have the shell access to run the script , i dont wish to run the function over the web server plus i see what the problems will be from standard out
Not tested, but you get the idea. Use func_get_arg to get the function name and call it like $functioname(). func_get_arg(0) is the filename, then starts the options. You can use --option-name syntax if you want as well (like shell scripts do). <?php if (isset(func_get_arg(1)) && is_function(func_get_args(1))) { {func_get_args(1)}(); // Pass variable params as well if you want, but check for them // {func_get_args(1)}(func_get_args(2)); } else { die('Invalid function call'); } function hello() { echo 'Hello'; } function hello2() { echo 'Hello 2'; } PHP:
(G3).. read the full post ass this is not over the web-sever its via the command prompt shell and it wordpress so we are to calling any other file but-in in the function one