PHP passes objects across servers

Source: Internet
Author: User
Tags yii

Recently because of research cross-domain name, cross-server problem, so bored, think of a cross-server problem of passing objects.

To pass data across servers, use a GET or post submission.

My method here is a bit complicated, but because of the usual work, there is a corresponding class library, so the implementation is relatively simple.

Look at the code first:

 Public functionactionsleeptest () {$user= User::model ()find (); //Echo $user->username; Var_dump ($user);        $data[' Name ']=Serialize($user); //$data [' name '] = "1315464";        $post=NewPostcurl (); $msg=$post->simulationpost (' HTTP//domain/index.php?r=site/wakeuptest ',$data,TRUE); Echo $msg; //echo $data [' name '];    }     Public functionactionwakeuptest () {$user=unserialize($_post[' Name ']); Var_dump($user); }

Should not be difficult to understand, using the YII framework this is very well understood.

PostURL is of course the analog submission post data

This is the perfect place to invoke the user object in Wakeuptest.

Of course there are no cross-domain names, but it is also possible to use the same type of user class created by the YII framework on another server.

Pillbox, you can also serialize the class, directly stored on the server, so that the pillbox day.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.