3

I'm having some problems with the function pcntl_fork() in php.

I'm using XAMPP and I'm trying to use that function and keeps me showing this error:

Call to undefined function pcntl_fork()

I dig something on Google and in XAMPP forums but couldn't find anything totally useful. I found some forums saying that i need to enable some configuration called

--enable-pcntl

I saw the phpinfo() and i have that option in the configure command. Can you help me?

Thanks in adavnce,

Elkas

hakre
  • 193,403
  • 52
  • 435
  • 836
Elkas
  • 603
  • 12
  • 27

3 Answers3

2

@Elkas, I don't know your XAMPP version, but XAMPP 1.8.0 on my computer is with pcntl extension. You can try command "/opt/lampp/bin/php -m | grep 'p' " to check the extension list of your php.

tempslar
  • 46
  • 4
  • Hi, thanks for the tip. I had the 1.7.2 Version but now I use AMPPS. In that time I solved it with a clean installation of XAMPP, but after that we decided to go though another solution. Thanks for the answer. – Elkas Dec 20 '12 at 17:09
2

Note:

Currently, this module will not function on non-Unix platforms (Windows).

http://php.net/manual/en/pcntl.installation.php

RafaSashi
  • 16,483
  • 8
  • 84
  • 94
1

It is configuration, but not runtime. It's compile time configuration. When compiling you have to do:

./configure --enable-pcntl
make
make install

If it's not compiled in you can't enable it without recompiling.

NickSoft
  • 3,215
  • 5
  • 27
  • 48
  • 1
    His statement says that `phpinfo()` suggests that it was compiled that way by default. – Glen Solsberry Mar 30 '11 at 18:19
  • After the installation of XAMPP how can i do that? – Elkas Mar 30 '11 at 18:26
  • yes, it says that was compiled by default. So i don't know why is not working. – Elkas Mar 30 '11 at 18:27
  • Even a simple file with isn't working. – Elkas Mar 30 '11 at 18:29
  • @Elkas - yes. I missed that. May be there are 2 installations of php on the same machine. What if ubunto has php and you installed XAMPP. Are you sure you've run phpinfo() and the your fork() script on the same interpreter? If you run phpinfo() on web server and fork on php cli then it's possible that web server is using different PHP installation – NickSoft Mar 30 '11 at 18:52
  • Probably. I run the script from the same folder as the project. About the another PHP installation i didn't find any. I'll try to remove Xampp and install it manually, component by component. Apache, and MYSQL. I'll give you some feed back later =) – Elkas Mar 30 '11 at 19:05
  • Try to put this in the same file: var_dump(function_exists("pcntl_fork")); phpinfo(); – NickSoft Mar 30 '11 at 20:39
  • ok... I have this output bool(false) for the var_dump(function_exists("pcntl_fork")), and for the phpinfo() i have the common pp info output. I suppose that my PHP localhost server doesn't have the feature enable. – Elkas Mar 30 '11 at 22:18
  • I've solved the problem with some async functions =) Thanks for the quick answers. – Elkas Apr 01 '11 at 09:39