<?php
/*
filename : serialize.php (ver.0.0.1)
email : hwooky@phpclass.com
homepage : www.phpclass.com
author : hwooky
*/
/*
사용자 함수:
string serialize3(mixed value, string classname);
mixed unserialize3(string str);
*/
function prvExplodeGroup($str) {
$count = 0;
$prefix = $middle = $suffix = "";
do {
$pos_start = ($pos_start = strpos($str, "{")) ? $pos_start : "NOTHING";
$pos_end = ($pos_end = strpos($str, "}")) ? $pos_end : "NOTHING";
if ((string)$pos_start < (string)$pos_end) {
// "{"로 시작되는 부분
if (0 == $count) {
$prefix = substr($str, 0, $pos_start);
$str = substr($str, $pos_start+1);
} else {
$middle .= substr($str, 0, $pos_start)."{";
$str = substr($str, $pos_start+1);
}
$count++;
} else if ((string)$pos_start > (string)$pos_end) {
// "}"로 시작되는 부분
$middle .= substr($str, 0, $pos_end)."}";
$str = substr($str, $pos_end+1);
$count--;
}
} while ($count);
if ($middle) {
$middle = substr($middle, 0, -1);
$suffix = $str;
} else {
$prefix = $str;
}
return array($prefix, $middle, $suffix);
}
function prvSimplifyObjectString($str) {
$pos = strpos($str, "{");
$prefix = substr($str, 0, $pos);
$val = substr($str, $pos+1, -2);
$suffix = $val;
$str = "";
$count = 0;
do {
list($prefix, $middle, $suffix) = prvExplodeGroup($suffix);
if ($middle)
$str .= $prefix.$count++.";";
} while ($middle);
return $str.$prefix;
}
function serialize3(&$obj, $classname="") {
$str = serialize($obj);
return $classname.";".$str;
}
function unserialize3($str) {
$pos = strpos($str, ";");
$classname = substr($str, 0, $pos);
$val = substr($str, $pos+1);
$obj = unserialize($val);
if ($classname && function_exists($classname)) {
$tobj = new $classname;
$val = prvSimplifyObjectString($val);
$arg = explode(";", $val);
for ($i=0;$i<sizeof($arg);$i+=2) {
$sep = explode(":", $arg[$i]);
$name = substr($sep[2], 1, -1);
if ("user function" != gettype($tobj->$name))
$tobj->$name = $obj->$name;
}
return $tobj;
}
return $obj;
}
?>$obj = new test;
serialize3($obj, "test");
<?php
// 파일명 : test1.php3
require("./serialize.php");
class test {
var $a;
var $b;
function output() {
return "나 함수";
}
}
$obj = new test;
$obj->a = 0;
$obj->b = "나 b";
echo "<p>".$obj->a."</p>";
echo "<p>".$obj->b."</p>";
echo "<p>".$obj->output()."</p>";
$ser = urlencode(serialize3($obj, "test"));
echo "<p><A href=test2.php3?ser=$ser>TEST2.PHP3</A></p>";
?> <?php
// 파일명 : test2.php3
require("./serialize.php");
class test {
var $a;
var $b;
function output() {
return "나 함수";
}
}
$obj = unserialize3(stripslashes($ser));
echo "<p>".$obj->a."</p>";
echo "<p>".$obj->b."</p>";
echo "<p>".$obj->output()."</p>";
?>
<p><A href=test1.php3>TEST1.PHP3</A></p>2012-3--17 You will realize that you simply oakley sunglassesare looking at oakleysa fake pair of eyeglasses with bad level of quality by looking fake oakleys at its edges, color, workmanship, along using oakley outlet components employed in its production. When searching for replica Oakleys, appear oakley sunglasses outleton how the sunlight eyeglasses have been made to steer obvious of getting the incorrect one. Lastly, the major place cheap oakley sunglasses acquiring replica Oakleys is not merely adapting to trends but in add-on providing your do it yourself an superb chance to conserve in your budget. However, be good that you simply purchase level of quality replicas that could pass for genuine eyewear in appearance Then why would you conserve up just to commit your hard-earned money to acquire an genuine pair whenever you can obtain the quality, discount oakley sunglasses durability, and intent you have frequently wanted from cheap cheap oakley sunglasses cheap. By acquiring a replica oakley sunglasses online shop cheap oakley sunglasses, not merely have you been producing your do it yourself an oakley online shop trendsetter but you are also proving your oakley sunglasses for fake it yourself as an superb economist collectively with a smart purchaser who understands when to commit and when not to.The fake cheap oakley sunglasses oakley factroy outlet of the broad choice of styles. oakleys sale not all-styles possess a vintage look, and some even have blue lenses. If is your style oakley factroy store or merely just one of your favored celebrities, Using mens oakley sunglasses minimum amount amount of cash, you can currently possess oakley sunglasses for women assortment of replica cheap cheap oakley sunglasses with different colours and variations to decide on oakley sunglasses for men When getting even a replica cheap cheap oakley sunglasses observe the workmanship and contemplate women oakley sunglasses every pair was also devoted with producing knowledge to provide a level of quality product suited http://oakleysunglassesoutlets2012.com the every style and useful needs.
| 번호 | 제목 | 닉네임 | 조회 | 등록일 | 최근 수정일 | 상태 |
|---|---|---|---|---|---|---|
| 5 |
1.클래스와 인스턴스
|
joy24 |
60 | 2000-10-17 | 2000-10-17 13:15 | 완료 |
| 4 | 2.Serialize/Unserialize [1] | joy24 |
57 | 2000-10-19 | 2012-03-17 10:58 | 완료 |
| 3 | 3.PHP4에서 메소드를 Serialize/Unserialize하기 | joy24 |
74 | 2000-10-19 | 2000-10-19 14:40 | 완료 |
![]() |
4.PHP3에서 메소드를 Serialize/Unserialize하기 [1] | joy24 |
41 | 2000-10-19 | 2012-03-17 10:54 | 완료 |
| 1 | 5.객체의 형변환(type casting) [1] | joy24 |
109 | 2000-10-19 | 2012-03-20 14:23 | 완료 |
아이디가 없으신 분은
회원가입 후 이용하실 수 있습니다.
