함수 file2ext()

Jmnote (토론 | 기여)님의 2021년 10월 13일 (수) 17:38 판 (→‎PHP)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

  • /etc/os-release → ""
  • /etc/httpd/conf/httpd.conf → conf

2 JavaScript[ | ]

function file2ext(x) {
    return x.substring(x.lastIndexOf('.')+1);
}
console.log( file2ext('/etc/os-release') );
console.log( file2ext('/etc/httpd/conf/httpd.conf') );
console.log( file2ext('/var/www/html/mediawiki-1.2.3.tar.gz') );

3 PHP[ | ]

function file2ext($x) {
    return pathinfo($x)['extension'] ?? '';
}
var_dump( file2ext('/etc/os-release') );
var_dump( file2ext('/etc/httpd/conf/httpd.conf') );
var_dump( file2ext('/var/www/html/mediawiki-1.2.3.tar.gz') );

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}