php class를 관리

· 17년 전 · 1941
추천: 0 , 조회: 79
ㅇ php.net의 class관련 소스들을 응용해서 java의 패키지형식으로 소스를 관리하도록 만들어 봤습니다.
ㅇ php에서 작성한 class의 위치를 /lib/class로 설정하고
class밑의 디렉토리를 java 패키지 같이 설정하여 사용합니다.

ex) /lib/class/common/class.common.object.php
/lib/class/util/class.util.string.php
/lib/class/cont/class.cont.photo.php
ㅇ 생성되는 class는 각자의 성격에 맞는 폴더 아래에서 관리하는거죠!

/********** class.common.object.php ************/
class class_common_object
{
var $m_name = '';
function class_common_object($name)
{
$this->m_name =$name;
register_shutdown_function(array(&$this, '_class_common_object'));
}

function _class_common_object()
{
}

function getName() { return $this->m_name; }
}


/********** func.class.php ************/
function &func_classFactory($classfilename)
{

$classname = func_classInclude($classfilename);
if (!$classname) return;

$code = "return new {$classname}(";
if (func_num_args() > 1)
{
$params = array_slice(func_get_args(),1);
$c = count($params);
for($i=0;$i<$c;++$i)
{
if ($i>0) $code .= ',';
$code .= '$params['.$i.']';
}
}
$code .= ');';
$csObj = eval($code);
return $csObj;
}

function func_classInclude($classfilename)
{
$clsarr = explode(".", $classfilename);
$classname = str_replace(".","_",$classfilename);

for($i=1; $i<count($clsarr)-1; $i++) $filename .= "/" . $clsarr[$i];
$filename =$g_arConfig[CLASS_ROOT] . $filename . "/$classfilename.php";

if (!class_exists($classname))
{
if (file_exists($filename)) include_once($filename);
else
{
echo "\nCould not load library $filename \n";
return null;
}
}
return $classname;
}


/*********** SAMPLE.PHP ***********/
include "func.class.php";
$csObj = func_classFactory("class.common.object", "test");
echo $csObj->getName();

[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 1,622
16년 전 조회 2,386
16년 전 조회 2,007
16년 전 조회 2,178
16년 전 조회 2,402
16년 전 조회 1,678
16년 전 조회 2,559
16년 전 조회 2,445
16년 전 조회 4,742
16년 전 조회 1,511
16년 전 조회 1,257
16년 전 조회 2,212
16년 전 조회 2,178
16년 전 조회 1,721
16년 전 조회 2,290
16년 전 조회 2,495
16년 전 조회 1,599
16년 전 조회 1,957
16년 전 조회 2,129
16년 전 조회 1,211
16년 전 조회 1,926
16년 전 조회 1,607
16년 전 조회 2,105
16년 전 조회 1,525
16년 전 조회 2,429
16년 전 조회 2,094
16년 전 조회 6,119
16년 전 조회 2,113
16년 전 조회 3,899
16년 전 조회 1,655
16년 전 조회 1,949
16년 전 조회 2,293
16년 전 조회 2,818
16년 전 조회 2,520
16년 전 조회 2,956
16년 전 조회 3,201
16년 전 조회 3,219
17년 전 조회 2,009
17년 전 조회 1,737
17년 전 조회 1,603
17년 전 조회 1,935
17년 전 조회 1,418
17년 전 조회 2,171
17년 전 조회 1,943
17년 전 조회 1,800
17년 전 조회 1,503
17년 전 조회 2,376
17년 전 조회 3,439
17년 전 조회 2,343
17년 전 조회 1,942
17년 전 조회 1,717
17년 전 조회 2,246
17년 전 조회 4,934
17년 전 조회 1,651
17년 전 조회 2,384
17년 전 조회 2,346
17년 전 조회 2,625
17년 전 조회 2,341
17년 전 조회 4,664
17년 전 조회 3,157
17년 전 조회 3,077
17년 전 조회 1,785
17년 전 조회 1,436
17년 전 조회 4,168
17년 전 조회 1,840
17년 전 조회 1,841
17년 전 조회 2,320
17년 전 조회 2,085
17년 전 조회 1,721
17년 전 조회 4,140
17년 전 조회 1,965
17년 전 조회 3,306
17년 전 조회 3,236
17년 전 조회 1,224
17년 전 조회 2,044
17년 전 조회 1,800
17년 전 조회 2,044
17년 전 조회 2,864
17년 전 조회 3,227
17년 전 조회 3,435
17년 전 조회 3,537
17년 전 조회 1,644
17년 전 조회 1,630
17년 전 조회 2,430
17년 전 조회 2,193
17년 전 조회 2,481
17년 전 조회 3,014
17년 전 조회 3,495
17년 전 조회 2,580
17년 전 조회 1,853
17년 전 조회 3,432
17년 전 조회 3,278
17년 전 조회 3,254
17년 전 조회 4,128
17년 전 조회 2,763
17년 전 조회 2,629
17년 전 조회 2,874
17년 전 조회 3,117
17년 전 조회 2,831
17년 전 조회 1,670