增加load_obj_from_jsonfile函数,用于将文件载入并使用json_decode解码为php对象

This commit is contained in:
hyzboy 2016-08-30 16:00:29 +04:00
parent a02de1f221
commit 054b99a331
2 changed files with 27 additions and 0 deletions

View File

@ -3,6 +3,7 @@
require_once 'tools.php';
require_once 'tools_session.php';
require_once 'tools_file.php';
require_once 'form/form_editbox.php';
require_once 'form/form_button.php';

26
tools_file.php Normal file
View File

@ -0,0 +1,26 @@
<?php
function load_obj_from_jsonfile($filename)
{
$file=file_get_contents($filename);
if($file)
{
$result=json_decode($file,true);
if($result)
{
return $result;
}
print_r(json_last_error_msg());
}
else
{
print_r("file_get_contents error");
}
exit;
}