質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,32 @@
|
|
1
1
|
調べても出てこなかったので質問なのですが、
|
2
2
|
PHPでロード済みのクラスをアンロードすることはできるのでしょうか?
|
3
3
|
|
4
|
-
namespace、class名を変更しろ!!の突っ込みはなしでお願いします。
|
4
|
+
namespace、class名を変更しろ!!の突っ込みはなしでお願いします。
|
5
|
+
```PHP
|
6
|
+
//■Test1.php
|
7
|
+
class TestClass {
|
8
|
+
function test() {
|
9
|
+
echo "test1";
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
//■Test2.php
|
15
|
+
class TestClass {
|
16
|
+
function test() {
|
17
|
+
echo "test2";
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
//■処理(下記みたいに処理をしたときにエラーにならないようにできる??)
|
23
|
+
// Cannot declare class TestClass, because the name is already in use
|
24
|
+
require_once Test1.php;
|
25
|
+
//※アンロード処理
|
26
|
+
require_once Test2.php;
|
27
|
+
|
28
|
+
$obj = new TestClass();
|
29
|
+
$obj->test(); // ここでtest2を出す
|
30
|
+
|
31
|
+
|
32
|
+
```
|