php - 有没有办法将类内部的变量传递给php外部的函数?
问题描述
我正在编写一个小“显示更多”按钮,该按钮使用 ajax 从服务器检索数组。它似乎与在函数内声明和设置的正常响应一起工作,但我无法从现有类中的变量中检索数据。
namespace Elementor;
class DB_Gallery extends \Elementor\Widget_Base {
public $dbg_more = array();
protected function render() {
//Some code here
$this->dbg_more[] = array(some data)
}
}
function db_gallery_loadmore() {
$db_gallery = new DB_Gallery;
$response = $db_gallery->dbg_more;
}
我预计这会奏效,但在课堂外却没有。里面一切都像预期的那样工作。我试图传递的数据是一个数组数组。每次必须插入元素时,我都使用这行代码来执行此操作:
$dbg_more[] = array( 'id'=>$image['id'], 'url'=>$image['url'], 'type'=>$image['type'] );
解决方案
推荐阅读
- laravel - Laravel 多次检索已删除的用户
- windows - 如何在 Windows 10 上显示 Android Studio IDE 颜色
- python - Tensorflow GRU 层调用()参数——TypeError:调用()得到了一个意外的关键字参数“reset_after”
- c - 无法保存从 ESP32Cam 模块拍摄的正确 jpg 格式图片,并且无法在 Windows 中打开
- java - 无法找到请求目标的有效证书路径 (SSLHandshakeException)
- entity-framework-core - 使用 FORMAT 命令转换 SQL 查询以在实体框架核心中使用
- python - 如何使用 Python 从相机 (Nikon D5600) 读取图像文件
- maven - 无法解析 gmaven 插件中的类 util
- python - 如何使用python从子目录下的文件名中删除多个字符?
- elasticsearch - 在聚合中添加脚本 - 弹性搜索