Pawl
Pawl copied to clipboard
send variable
HI,
I would like to retrieve the variable $argv[1] but I can't.
<?php
require __DIR__ . '/vendor/autoload.php';
\Ratchet\Client\connect('wss://echo.websocket.org:443')->then(function($conn) {
$conn->on('message', function($msg) use ($conn) {
echo "Received: {$msg}\n";
$conn->close();
});
$conn->send($argv[1]);
}, function ($e) {
echo "Could not connect: {$e->getMessage()}\n";
});
Hi,
You need to pass $argv from the parent context to the anonymous function context like you did with $conn :
\Ratchet\Client\connect('wss://echo.websocket.org:443')->then(function($conn) use($argv) {
Hi,
Thank you very much, it works :)