티스토리 뷰

PHP

php constants 키 이름 알아내기

🩷 슈 🧡 2013. 2. 27. 16:58
728x90
SMALL

<?php

class LogingEvent {

const Run = 0;

const RunDevilRun = 1;

public function getConstants($type) {

$x = $type;

$fooClass = new ReflectionClass ( 'LogingEvent');

$constants = $fooClass->getConstants();

$constName = null;

foreach ( $constants as $name => $value )

{

if ( $value == $x )

{

$constName = $name;

break;

}

}

return $constName;

}

}



예)
$aaa = LogEvent::getConstants( LogEvent::RunDevilRun );
echo $aaa;

결과 > RunDevilRun

728x90
LIST

'PHP' 카테고리의 다른 글

asp, php, jsp 사용자 ip 확인  (0) 2013.06.08
코드이그나이터 Codeigniter index.php 없애기.  (0) 2013.06.05
php error 리포트  (0) 2012.11.28
tail -f debug.log  (0) 2012.03.12
이클립스 > Remote System Explorer 설정  (0) 2012.01.17
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함
250x250