peb (PHP-Erlang Bridge) is an open-source PHP extension to run PHP as an Erlang cnode.

It's similar to the traditional php mysql function , you can easily communicate with an Erlang node.

The following is an example:

```

$link = peb_connect('sadly-desktop@sadly-desktop', 'secret');

if (!$link) {

die('Could not connect: ' . peb_error());

}

$msg = peb_vencode('[~p,~a]', array(

array($link,'getinfo')

)

);

//The sender must include a reply address. use ~p to format a link identifier to a valid Erlang pid.

pebsendbyname('pong',$msg,$link);

$message = peb_receive($link);

$rs= peb_vdecode( $message) ;

print_r($rs);

$serverpid = $rs[0][0];

$message = peb_vencode('[~s]', array(

array('how are you')

)

);

pebsendbypid($serverpid,$message,$link);

//just demo for how to use pebsendbypid

peb_close($link);

?>

```

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐