0
class testing extends Thread {
    public $client;
    public function __construct($persons) { // set passed arguments
        $this->persons = $persons;
    }
    public function run() { // run thread
        $this->client = new Services_Twilio('my_id', 'my_token');
        printf('%s: %s' . "<br>", date("g:i:sa"), $this->client->account->sms_messages->create($this->persons[0], $this->persons[1], $this->persons[2])->sid);
    }
}

$testing= new multipleSMS(['+XXXXXXXXXXXX', 'xxx-xxx-xxxx', 'A sample message']);
$testing->start();

This gives me the error: Warning: in_array() expects parameter 2 to be array, null given in twilio-php-master\Services\Twilio.php on line 59. So at $this->client I am giving it an array. And when I use the new services_twilio class outside of the thread it works just fine.

What am I doing wrong.

0

1 Answer 1

1

You don't intend to share $this->client, so do not set it as a member of the thread, keep it in the method scope, avoid locking and serialization in this way.

Only share what is designed to be shared (descending from pthreads) and requires sharing (you intend to access it from another context).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.