php跨伺服器傳遞對象

來源:互聯網
上載者:User

標籤:style   blog   http   color   使用   os   io   資料   

最近因為研究跨網域名稱,跨伺服器的問題,所以無聊,就想到了一個跨伺服器傳遞對象的問題。

想要跨伺服器傳遞資料,那麼就要使用到get或者post提交。

我這裡的方法有點複雜,但是因為平時工作時,有封裝相應的類庫,所以實行起來也相對來簡單很多。

先看代碼:

  public function actionSleeptest(){        $user = User::model()->find();        //echo $user->username;        //var_dump($user);        $data[‘name‘]=serialize($user);        //$data[‘name‘] = "1315464";        $post = new postCurl();        $msg = $post->simulationPost(‘http://網域名稱/index.php?r=site/Wakeuptest‘,$data,TRUE);        echo $msg;        //echo $data[‘name‘];    }    public function actionWakeuptest(){        $user = unserialize($_POST[‘name‘]);        var_dump($user);    }

理解起來應該不難,用的是YII架構這個就很好理解了。

postUrl當然是類比提交post資料

這裡可以完美的在wakeuptest中調用User這個對象

當然這裡沒有跨網域名稱,但是如果在另一台伺服器上,也有一個YII架構建立的同類型的User類,那麼也是可以使用的。

碉咋天吧,還可以將類序列化後,直接存放在伺服器上,這樣就碉咋天了。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.