开发者

PHP RMI for a class

I have made a class file which are running on my s开发者_运维技巧erver.I am using it as a API.my some client will use it.In their program i have to create an object remotely of this class. How will use my class file as RMI that object can create easily on other server. Thanks


I don't think anything close to Java's RMI (as far as I understand it) can be done in PHP.

The best thing that comes to my mind is

  • Create an object in the remote script

  • Serialize that object

  • Return the serialized data to the calling script

  • Unserialize the data back into an object (note that all class definitions must be present locally for this to work!)

Note that things like active database connections, file handles and so on can not be transferred this way.

Whether this is a good - and fast enough - way to do what you want is hard to say. Maybe it helps.


To connect as a user other than 'anonymous', you need to specify the username (and possibly password) within the URL, such as 'ftp://user:password@ftp.example.com/path/to/file'. (You can use the same sort of syntax to access files via HTTP when they require Basic authentication.)

<?php
$file = fopen ("ftp://ftp.example.com/incoming/outputfile", "w");
if (!$file) {
    echo "<p>Unable to open remote file for writing.\n";
    exit;
}
/* Write the data here. */
fwrite ($file, $_SERVER['HTTP_USER_AGENT'] . "\n");
fclose ($file);
?>

http://php.net/manual/en/features.remote-files.php

include ("ftp://username:password@ftp.example.com/public_html/example.php");    
$class = new Ford();    
$dataRow = $class->consulta();
var_dump($conexion);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜