Home  >  Article  >  Backend Development  >  What to do if php socket cannot connect

What to do if php socket cannot connect

藏色散人
藏色散人Original
2022-11-09 10:34:283226browse

Solution to the problem that php socket cannot connect: 1. Check whether the socket extension is enabled in php; 2. Open the php.ini file and check whether "php_sockets.dll" is loaded; 3. Cancel "php_sockets.dll" Just comment status.

What to do if php socket cannot connect

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if the php socket cannot be connected?

Solve the problem of failure to connect using php socket

Recently I am using php js to create a multi-person chat function. At first, I wrote the code according to the online steps, but The following error always appears when executing php

Fatal error: Call to undefined function socket_create()

Then I google it again. There are many solutions online, so I will share my success story.

First check whether the socket extension is enabled in php

This is because I did not enable QAQ. . .

if(extension_loaded(‘sockets’)){
echo “已开启”;
}else{
echo “未开启”;
}

Check the php.ini document under the php installation path again

Pay attention to the version of php used and find the corresponding version. For example, mine:

D:\PHPTutorial\php\php-7.2.1-nts

Check whether php_sockets.dll is loaded

Pay attention to whether this line of code is commented. (Mine is in the comment state)

What to do if php socket cannot connect

If it is in the comment state, just remove the comment~~

What to do if php socket cannot connect

Recommended Study: "PHP Video Tutorial"

The above is the detailed content of What to do if php socket cannot connect. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn