Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to assign a value from inside callback? #3

Closed
rentstack opened this issue Nov 23, 2020 · 1 comment
Closed

How to assign a value from inside callback? #3

rentstack opened this issue Nov 23, 2020 · 1 comment

Comments

@rentstack
Copy link

Sorry, but I can't figure out how to assign a value to a variable that is outside a callback function.

$need_var = 0;
$redis->get('key', function ($result) use ($need_var) {
        var_dump($result);     //  example in my case display int(2) 
        $need_var = $result;  // did't work
});
var_dump($need_var);   // int(0)
@walkor
Copy link
Owner

walkor commented Nov 23, 2020

Hi rentstack.
workerman\redis can not do that.
Please use redis extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants