Home >Backend Development >PHP Tutorial >php save array variable to file_PHP tutorial

php save array variable to file_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:43:40837browse

I am developing a permission function recently. I hope that if the user selects the set permissions in the background, a php file corresponding to the user will be generated, so that as long as the user logs in, I will load the corresponding configuration file. Here we need to set the user The permission php array is saved to the php file. Let’s look at the implementation function

 代码如下 复制代码

function CreatePropertyArray(){
global $IP;

$content = '';
$industris = array();
$industry_tree = array();

$content .= "
//Industry
$industries = getMasterPropertyValues('Industry');
foreach($industries as $v){
$industry_tree["$v"]= getSlavePropertyValues("Industry","Product Category", $v);
}

$content .= '$Industries = '. var_export($industries,true) . ";n";

file_put_contents($IP . '/termwiki_array.php',$content,LOCK_EX);

}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633147.htmlTechArticleRecently, I want to develop a permission function. I hope that if the user selects the set permission in the background, a corresponding permission will be generated for the user. php file, so that as long as the user logs in, I will load the corresponding configuration...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn