| 추천: 0 , 조회: 79 |
ㅇ 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();
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 30 |
아우겐나이스
|
21년 전 | 4032 | |
| 29 |
아우겐나이스
|
21년 전 | 4430 | |
| 28 |
아우겐나이스
|
21년 전 | 3449 | |
| 27 | 21년 전 | 5814 | ||
| 26 | 21년 전 | 3084 | ||
| 25 | 21년 전 | 6065 | ||
| 24 | 18년 전 | 3637 | ||
| 23 | 21년 전 | 3627 | ||
| 22 | 21년 전 | 4235 | ||
| 21 | 21년 전 | 3811 | ||
| 20 | 21년 전 | 4209 | ||
| 19 | 21년 전 | 6668 | ||
| 18 | 21년 전 | 4727 | ||
| 17 | 21년 전 | 6970 | ||
| 16 | 21년 전 | 4161 | ||
| 15 | 21년 전 | 2615 | ||
| 14 | 21년 전 | 4960 | ||
| 13 | 21년 전 | 3391 | ||
| 12 |
Recluse
|
21년 전 | 3863 | |
| 11 |
아우겐나이스
|
21년 전 | 3558 | |
| 10 |
Recluse
|
21년 전 | 3386 | |
| 9 | 21년 전 | 3965 | ||
| 8 | 21년 전 | 5152 | ||
| 7 | 21년 전 | 4749 | ||
| 6 | 21년 전 | 5662 | ||
| 5 | 21년 전 | 4102 | ||
| 4 | 21년 전 | 4821 | ||
| 3 | 21년 전 | 4733 | ||
| 2 | 21년 전 | 3231 | ||
| 1 | 22년 전 | 4331 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기