简体   繁体   English

在PHP的类中包含变量

[英]Include variables into a class in PHP

I'am trying to write a function that includes any variable into a classs. 我正在尝试编写一个将任何变量都包含到类中的函数 For example: 例如:

My function: add_action($VARS_ARRAY); 我的函数:add_action($ VARS_ARRAY);

This function should include $VARS_ARRAY into A class. 此函数应将$ VARS_ARRAY包含在A类中。

How can I do it in PHP? 如何在PHP中做到这一点?

you don't need a function for this, you can just add a value directly. 你不需要这个功能,你可以直接添加一个值。

$a = new A();
$a->vars_array = $VARS_ARRAY;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM