Uncaught Error: Undefined constant AF_NET - PHP Socket - php

*Hello everyone, I got AF_NET error using php socket.
I try to found on multiple post, but all enable this extension=sockets or extension=php_sockets.dll in their php.ini and work.
I enable both and separately on my php.ini of my XAMPP in Windows, I resolve the Undefined socket_create but now I get this error and nothing works. Try to restart Xampp also.
If someone know and can help me please I would be very happy 😪 !
AF_NET undefined
Here is my code below to create a php socket :

Related

How to conncect Oracle with PHP under Winginx?

I want to use PHP to connect to Oracle, but get an error:
Fatal error: Call to undefined function oci_connect()...
I searched in Google, and get that the OCI is not enabled in PHP, but after install Ora10InstantClient & enable extension=php_oci8_12c.dll , I still get the error.
I checked phpinfo(), found the "configure command" -> with-oci8-12c= ... was WRONG. How do I fix this path? If this is not this problem, how can I resolve the problem?

Call to undefined function curl_init() in wampp

I am getting an error. I have done the following:
Find file php.ini and uncomment in wamp apache folder
Find file php.ini and uncomment in wamp php folder
checked in wamp extensions
download file and replace php_curl-5.3.13-nts-VC9-x64.zip
restart wamp.
But I still get error
Fatal error: Call to undefined function curl_init() in C:\wamp\www\wordpress\wp-content\plugins\test\curl_http_client.php on line 66
Call to undefined function curl_init
You either edit wrong php.ini file or something is missing on your system, preventing curl extension from loading. You shall check with phpinfo() where is proper php.ini, then check if you got extension entry for cURL really enabled. If so and it is still not working then next step should be checking Apache's error.log looking for detailed error messages from PHP.

phpwebsocket - Undefined Function socket_create() - Have php_sockets enabled on Windows/WAMP

I checked out the PhpWebSockets project from here:
https://code.google.com/p/phpwebsocket/
It's in its own project on my localhost (Windows 7 64-bit) box, inside of a WAMP server. I issue the following command in Windows Command Line to run the server.php file:
C:\wamp\bin\php\php5.4.12\php.exe C:\wamp\www\phpwebsocket\server.php
But it results in the following error message:
PHP Fatal error: Call to undefined function socket_create() in C:\wamp\www\phpwebsocket\server.php on line 58
My WAMP instance DOES have the php_sockets extension enabled (since I saw this similar question who had that problem).
Anyone know what I could possibly be doing wrong?
Found the answer in another thread:
Error with PHP Websocket and Wamp Server
Turns out running the file on the command line means it uses a different php.ini file than the WAMP server does. Seems stupid, but turned out php_sockets wasn't uncommented in that php.ini file, and removing it removed the error with it.

Fatal error: Call to undefined function printer_open()

I'm trying to print some string using PHP, i'm using the PHP print functions:
$printer = ("HP LaserJet Professional P1102");
$handler= printer_open($printer);
$content="Test Content";
printer_write($handler, $content);
printer_close($handler);
but I got that error :
Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\print.php on line 12
after googling it i found that i must add the php_printer.dll to the extensions file in php and add it's extension to the php.ini file, then restarting the server services, all of that accomplished but still getting that error.
p.s. I've tried it on WAMP and XAMPP
I think solution would be extension location.php_printer extension should be stored in c:\xampp\php\ext and not in c:\xampp\php. So move it to the ext-folder, and restart Apache.
Can you look into the error_log, which tells you, if it fails to load the module. You should also run a phpinfo(), which shows up all loaded modules, you must find the printer extensions there.
I hope it may resolve your issue.

apns not connecting in php

i am new to push notifications and tried following to fix this but it still gives same error.
added C:\PHP\ext to the Windows path
added libeay32.dll and ssleay32.dll to C:\WINDOWS\system32\inetsrv
rebooted the server
first error:-
Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (0)' in C:\wamp\www\ApnsPHP-master\ApnsPHP\Abstract.php on line 396
second error:-
ApnsPHP_Exception: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (0) in C:\wamp\www\ApnsPHP-master\ApnsPHP\Abstract.php on line 396
i am using a .pem file which was used before somewhere else
and also i am trying to run my file on localhost, does it matter ?
if someone knows something that what should i do to fix this error, then please help me !
and thanx in advance
You should look if SSL is enabled in your configuration.
To display your configuration simply copy/paste the following in some php file and browse to it with a browser:
<?php
phpInfo();
?>

Categories