首页 > 解决方案 > 如手册中所述,如何在 php 中启用套接字?

问题描述

我已经安装了 Xampp 并且想在 php 中使用套接字,所以我从localhost 上的http://php.net/manual/en/sockets.examples.php的示例代码开始。我得到了这个众所周知的错误:

致命错误:在第 14 行调用 C:\xampp\htdocs\simpletcpipserver.php 中未定义的函数 socket_create()

在网上搜索后,我更改了 PHP.ini 文件:我删除了;fromextension=php_sockets.dll并将这部分编辑为:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = C:\xampp\php\ext

php_sockets.dll 存在于该位置。

但我仍然得到同样的错误。

我确实在http://php.net/manual/en/sockets.installation.php上看到了这个: The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.

除了我已经做过的,我不明白这意味着什么。

我现在应该让示例代码工作吗?

标签: phpsockets

解决方案


推荐阅读