function get_token_file_info() {
// Set File Path
$filename = file_path;
// File Open by Read Mode
$ofile = fopen($filename, 'r');
// Get File text
$token_value = fgets($ofile);
// Get File modify time
// Timestamp 값을 받아 오는데 msec 값을 제외한 10자리로 받아 온다.
// Javascript 에서는 13자리를 받기 때문에 뒤에 000 을 붙여서 주는 방법도 있음
$token_time = filemtime($filename);
// Get Current Time
$current_time = time();
$result['token_value'] = $token_value;
$result['token_time'] = $token_time;
$result['current_time'] = $current_time;
$this->output->set_content_type ( 'application/json' )->set_output ( json_encode ( $result ) );
}
fopen 링크 : http://php.net/manual/en/function.fopen.php
fgets 링크 : http://php.net/manual/en/function.fgets.php
filemtime 링크 : http://php.net/manual/en/function.filemtime.php
filectime 링크 : http://php.net/manual/en/function.filectime.php
'WEB개발 > php' 카테고리의 다른 글
| [php] curl POST/GET 처리 예제 (0) | 2019.01.07 |
|---|---|
| [php] socket client 처리 (0) | 2019.01.07 |
| [php] array로 return 시 list로 받아오기 (0) | 2019.01.07 |
| [php] array 관련 함수 (0) | 2019.01.07 |
| [php] foreach 반복문 (0) | 2019.01.07 |