php class를 관리

· 17년 전 · 1791
추천: 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,474
16년 전 조회 2,228
16년 전 조회 1,860
16년 전 조회 2,021
16년 전 조회 2,229
16년 전 조회 1,525
16년 전 조회 2,351
16년 전 조회 2,291
16년 전 조회 4,579
16년 전 조회 1,339
16년 전 조회 1,093
16년 전 조회 2,056
16년 전 조회 2,024
16년 전 조회 1,554
16년 전 조회 2,085
16년 전 조회 2,329
16년 전 조회 1,435
16년 전 조회 1,786
16년 전 조회 1,969
16년 전 조회 1,061
16년 전 조회 1,742
16년 전 조회 1,448
16년 전 조회 1,948
16년 전 조회 1,362
16년 전 조회 2,256
16년 전 조회 1,943
16년 전 조회 5,911
16년 전 조회 1,962
16년 전 조회 3,732
16년 전 조회 1,517
16년 전 조회 1,804
16년 전 조회 2,113
16년 전 조회 2,651
16년 전 조회 2,361
16년 전 조회 2,790
16년 전 조회 3,039
16년 전 조회 3,058
16년 전 조회 1,870
16년 전 조회 1,589
16년 전 조회 1,461
16년 전 조회 1,773
16년 전 조회 1,247
16년 전 조회 2,014
16년 전 조회 1,779
16년 전 조회 1,655
17년 전 조회 1,336
17년 전 조회 2,212
17년 전 조회 3,278
17년 전 조회 2,210
17년 전 조회 1,792
17년 전 조회 1,558
17년 전 조회 2,088
17년 전 조회 4,779
17년 전 조회 1,461
17년 전 조회 2,194
17년 전 조회 2,172
17년 전 조회 2,445
17년 전 조회 2,194
17년 전 조회 4,475
17년 전 조회 2,976
17년 전 조회 2,919
17년 전 조회 1,643
17년 전 조회 1,289
17년 전 조회 3,993
17년 전 조회 1,666
17년 전 조회 1,660
17년 전 조회 2,159
17년 전 조회 1,937
17년 전 조회 1,543
17년 전 조회 3,963
17년 전 조회 1,794
17년 전 조회 3,174
17년 전 조회 3,045
17년 전 조회 1,083
17년 전 조회 1,894
17년 전 조회 1,640
17년 전 조회 1,895
17년 전 조회 2,680
17년 전 조회 3,072
17년 전 조회 3,265
17년 전 조회 3,367
17년 전 조회 1,510
17년 전 조회 1,461
17년 전 조회 2,294
17년 전 조회 2,024
17년 전 조회 2,336
17년 전 조회 2,857
17년 전 조회 3,311
17년 전 조회 2,408
17년 전 조회 1,678
17년 전 조회 3,253
17년 전 조회 3,115
17년 전 조회 3,093
17년 전 조회 3,958
17년 전 조회 2,635
17년 전 조회 2,451
17년 전 조회 2,697
17년 전 조회 2,936
17년 전 조회 2,657
17년 전 조회 1,495