php class를 관리

· 17년 전 · 1778
추천: 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,463
16년 전 조회 2,224
16년 전 조회 1,854
16년 전 조회 2,017
16년 전 조회 2,221
16년 전 조회 1,517
16년 전 조회 2,347
16년 전 조회 2,284
16년 전 조회 4,571
16년 전 조회 1,333
16년 전 조회 1,087
16년 전 조회 2,050
16년 전 조회 2,018
16년 전 조회 1,548
16년 전 조회 2,076
16년 전 조회 2,317
16년 전 조회 1,426
16년 전 조회 1,780
16년 전 조회 1,961
16년 전 조회 1,056
16년 전 조회 1,738
16년 전 조회 1,442
16년 전 조회 1,942
16년 전 조회 1,354
16년 전 조회 2,247
16년 전 조회 1,930
16년 전 조회 5,907
16년 전 조회 1,954
16년 전 조회 3,724
16년 전 조회 1,506
16년 전 조회 1,797
16년 전 조회 2,108
16년 전 조회 2,643
16년 전 조회 2,352
16년 전 조회 2,786
16년 전 조회 3,028
16년 전 조회 3,050
16년 전 조회 1,863
16년 전 조회 1,580
16년 전 조회 1,455
16년 전 조회 1,767
16년 전 조회 1,242
16년 전 조회 2,005
16년 전 조회 1,771
16년 전 조회 1,649
17년 전 조회 1,327
17년 전 조회 2,205
17년 전 조회 3,273
17년 전 조회 2,201
17년 전 조회 1,779
17년 전 조회 1,549
17년 전 조회 2,085
17년 전 조회 4,771
17년 전 조회 1,458
17년 전 조회 2,187
17년 전 조회 2,165
17년 전 조회 2,434
17년 전 조회 2,184
17년 전 조회 4,469
17년 전 조회 2,967
17년 전 조회 2,910
17년 전 조회 1,635
17년 전 조회 1,284
17년 전 조회 3,988
17년 전 조회 1,654
17년 전 조회 1,652
17년 전 조회 2,152
17년 전 조회 1,923
17년 전 조회 1,535
17년 전 조회 3,957
17년 전 조회 1,788
17년 전 조회 3,170
17년 전 조회 3,039
17년 전 조회 1,076
17년 전 조회 1,885
17년 전 조회 1,633
17년 전 조회 1,885
17년 전 조회 2,677
17년 전 조회 3,067
17년 전 조회 3,256
17년 전 조회 3,362
17년 전 조회 1,503
17년 전 조회 1,455
17년 전 조회 2,292
17년 전 조회 2,017
17년 전 조회 2,324
17년 전 조회 2,849
17년 전 조회 3,299
17년 전 조회 2,397
17년 전 조회 1,671
17년 전 조회 3,245
17년 전 조회 3,109
17년 전 조회 3,085
17년 전 조회 3,955
17년 전 조회 2,631
17년 전 조회 2,446
17년 전 조회 2,690
17년 전 조회 2,930
17년 전 조회 2,648
17년 전 조회 1,491