增加load_obj_from_jsonfile函数,用于将文件载入并使用json_decode解码为php对象
This commit is contained in:
parent
a02de1f221
commit
054b99a331
@ -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
26
tools_file.php
Normal 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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user