autoload 경로 재 변경

kakao를 별도의 namespace로 분리
외부 class의 namespace 문제 해결
This commit is contained in:
2018-03-24 18:46:37 +09:00
parent dc507601f5
commit 037a29ad02
25 changed files with 44 additions and 241 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace sammo;
class Json{
private static function setHeaderNoCache(){
if(!headers_sent()) {
header('Expires: Wed, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
}
}
public static function encode($value, $pretty = false){
if($pretty){
$flag = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
}
else{
$flag = JSON_UNESCAPED_UNICODE;
}
return json_encode($value, $flag);
}
public static function decode($value){
return json_decode($value, true);
}
public static function die($value, $noCache = true, $pretty = false, $die = true){
if($noCache){
self::setHeaderNoCache();
}
header('Content-Type: application/json');
echo Json::encode($value, $pretty);
if($die){
die();
}
}
}