PHP Pthreads: Fatal Error: Class 'Thread' Not Found

php why I get Class 'Thread' not found

The pthreads extension cannot be used in a web server environment. It is only available in the CLI.

Whatever you're trying to do, you'll need to come up with another way of doing it.

Php Class 'Thread' not found

Whilst Hassan Ahmed's reply explains why pthreads shouldn't be used in a web server environment, that is not the cause of the error you're receiving.

The problem is that the pthreads binary you have downloaded was not built for the PHP version you are using. This causes a mismatch between the pthreads' binary API and PHP's module API that it integrates into. Judging by your PHP version, you should be using the 2.0.10 release of pthreads, since that was the last stable release for PHP 5.6 version.

Note that support for pthreads for PHP 5.x versions is no longer maintained. If you would like the latest bug fixes and features, then use PHP 7.x and pthreads v3.

PHP Fatal error: Class 'Threaded' not found in C:\xampp\htdocs\

The line

class Task extends Threaded

should be changed to

class Task extends Thread

as shown in the first example

class workerThread extends Thread

on the PHP.net Site



Related Topics



Leave a reply



Submit