php class를 관리

· 17년 전 · 1848
추천: 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,518
16년 전 조회 2,284
16년 전 조회 1,914
16년 전 조회 2,073
16년 전 조회 2,292
16년 전 조회 1,582
16년 전 조회 2,446
16년 전 조회 2,355
16년 전 조회 4,630
16년 전 조회 1,412
16년 전 조회 1,149
16년 전 조회 2,112
16년 전 조회 2,084
16년 전 조회 1,621
16년 전 조회 2,169
16년 전 조회 2,385
16년 전 조회 1,495
16년 전 조회 1,856
16년 전 조회 2,032
16년 전 조회 1,117
16년 전 조회 1,813
16년 전 조회 1,503
16년 전 조회 2,015
16년 전 조회 1,425
16년 전 조회 2,317
16년 전 조회 1,999
16년 전 조회 5,992
16년 전 조회 2,021
16년 전 조회 3,794
16년 전 조회 1,563
16년 전 조회 1,854
16년 전 조회 2,199
16년 전 조회 2,725
16년 전 조회 2,422
16년 전 조회 2,856
16년 전 조회 3,104
16년 전 조회 3,118
16년 전 조회 1,922
16년 전 조회 1,647
16년 전 조회 1,511
16년 전 조회 1,826
16년 전 조회 1,314
16년 전 조회 2,074
17년 전 조회 1,845
17년 전 조회 1,712
17년 전 조회 1,403
17년 전 조회 2,286
17년 전 조회 3,341
17년 전 조회 2,259
17년 전 조회 1,849
17년 전 조회 1,622
17년 전 조회 2,153
17년 전 조회 4,832
17년 전 조회 1,539
17년 전 조회 2,283
17년 전 조회 2,256
17년 전 조회 2,526
17년 전 조회 2,248
17년 전 조회 4,559
17년 전 조회 3,057
17년 전 조회 2,978
17년 전 조회 1,696
17년 전 조회 1,343
17년 전 조회 4,085
17년 전 조회 1,738
17년 전 조회 1,736
17년 전 조회 2,227
17년 전 조회 1,980
17년 전 조회 1,622
17년 전 조회 4,048
17년 전 조회 1,876
17년 전 조회 3,227
17년 전 조회 3,128
17년 전 조회 1,135
17년 전 조회 1,960
17년 전 조회 1,706
17년 전 조회 1,955
17년 전 조회 2,758
17년 전 조회 3,135
17년 전 조회 3,335
17년 전 조회 3,450
17년 전 조회 1,564
17년 전 조회 1,531
17년 전 조회 2,357
17년 전 조회 2,091
17년 전 조회 2,391
17년 전 조회 2,921
17년 전 조회 3,384
17년 전 조회 2,482
17년 전 조회 1,758
17년 전 조회 3,324
17년 전 조회 3,185
17년 전 조회 3,158
17년 전 조회 4,036
17년 전 조회 2,687
17년 전 조회 2,518
17년 전 조회 2,771
17년 전 조회 3,011
17년 전 조회 2,730
17년 전 조회 1,561