Re: [請益] 有沒有法子把 $this pass 掉
其實無法描述清楚大概是我改不掉,或要改很久的毛病了 :P
我試著寫一個假想的程式片段來描述吧!!
demo.thtml
<?php
//do something
$this->here();
?>
我改成
demo.php
<?php
//do something
here();
?>
然後在我自己的程式裏就可以載入它,但因為 here 沒定義,我就得生給它
my.php
<?php
function here()
{
//cheat code
}
require 'demo.php';
?>
這方法其實還不錯,都已經成功了
但我其實很想寫一支程式,不必去手動改 demo.php
my_want.php
<?php
//powerful cheat env. in need,I can't do it
require 'demo.thtml';
?>
目前是這樣
剛想到一個法子
my_try.php
<?php
class Cheat
{
function here()
{
//cheat code
}
ruquire 'demo.thtml';
}
$run=new Cheat;//make it run
?>
如上,既然我把整個 demo.thtml 載入到一個 class 裏了
那麼 $this 就指到 class 內部,我也就可以騙過它了
結果我得到一個錯誤訊息 :P
syntax error, unexpected T_REQUIRE, expecting T_FUNCTION in my_try.php
譯:小子,這樣想騙過我?不可以啦,再回去改一版試試
突然之間就 抖抖 了,唉..
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.179.152
推
07/13 18:42, , 1F
07/13 18:42, 1F
→
07/13 18:45, , 2F
07/13 18:45, 2F
→
07/13 18:45, , 3F
07/13 18:45, 3F
→
07/13 18:57, , 4F
07/13 18:57, 4F
※ 編輯: HuangJC 來自: 61.59.179.152 (07/14 02:40)
→
07/14 02:42, , 5F
07/14 02:42, 5F
→
07/14 02:42, , 6F
07/14 02:42, 6F
→
07/14 18:07, , 7F
07/14 18:07, 7F
→
07/14 18:47, , 8F
07/14 18:47, 8F
→
07/14 19:55, , 9F
07/14 19:55, 9F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章