如何将变量从一个函数传递到另一个函数并通过短代码显示

关闭。这个问题需要更加集中。它当前不接受答案。


想改善这个问题吗?更新问题, 使其仅通过编辑此帖子即可解决一个问题。

在8个月前关闭。

我正在尝试将变量从一个函数传递到另一个函数, 并通过短代码显示在前端。这是我的代码

          function user_last_logout(){
          global $userr;
          $userr = 'hi';

          } 

          function get_logout_time(){
          global $userr;
          echo $userr;  
          }
          add_shortcode('lastlogn', 'get_logout_time');

#1


你可以将函数的返回值设为所需的变量, 然后在另一个函数中调用它。像这样:

function user_last_logout()
{
    return 'hi';
}

function get_logout_time()
{
    echo user_last_logout();
}

add_shortcode('lastlogn', 'get_logout_time');

这是你想要的?

来源:

https://www.srcmini02.com/63420.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37631.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?