Struct ext_php_rs::prelude::ZendCallable [−][src]
pub struct ZendCallable<'a>(_);
Expand description
Implementations
Attempts to create a new ZendCallable
from a zval.
Parameters
callable
- The underlyingZval
that is callable.
Errors
Returns an error if the Zval
was not callable.
Attempts to create a new ZendCallable
by taking ownership of a Zval.
Returns a result containing the callable if the zval was callable.
Parameters
callable
- TThe underlyingZval
that is callable.
Attempts to create a new ZendCallable
from a function name. Returns
a result containing the callable if the function existed and was
callable.
Parameters
name
- Name of the callable function.
Example
use ext_php_rs::types::ZendCallable;
let strpos = ZendCallable::try_from_name("strpos").unwrap();
let result = strpos.try_call(vec![&"hello", &"e"]).unwrap();
assert_eq!(result.long(), Some(1));
Attempts to call the callable with a list of arguments to pass to the function.
You should not call this function directly, rather through the
call_user_func
macro.
Parameters
params
- A list of parameters to call the function with.
Returns
Returns the result wrapped in Ok
upon success. If calling the
callable fails, or an exception is thrown, an Err
is returned.
Example
use ext_php_rs::types::ZendCallable;
let strpos = ZendCallable::try_from_name("strpos").unwrap();
let result = strpos.try_call(vec![&"hello", &"e"]).unwrap();
assert_eq!(result.long(), Some(1));