curl in not getting enabled in php webserver (development) - php

I am on a windows 10 desktop and I have downloaded PHP 8.1 (8.1.8) from the official website of php. It is located in C:\Program Files\php-8.1.8-Win32-vs16-x64 and I have added it to system path. I have also uncommented the curl php extention in the php.ini-development and php.ini-production files:
My php directory has libcrypto-*.dll, libssl-*.dll and libssh2.dll just like mentioned on php's official website. But even after all that, whenever I try to use the php curl module, I get an error:
Fatal error: Uncaught Error: Call to undefined function curl_init() in .
Also when I save the following code in curl.php file:
<?php
echo "curl enabled: ";
var_dump(extension_loaded("curl"));
?>
and run it using php C:/curl.php, I get:
curl enabled: bool(false)

Related

Call to undefined function odbc_connect via command line (cmd) PHP5

I'm using PHP 5, Windows (IIS), and when i try access the file from command line, i get the following error (via browser, everything works great):
Fatal error: Uncaught Error: Call to undefined function odbc_connect()
My current code is:
$connection = odbc_connect(DATABASE, 'user', 'user', SQL_CUR_USE_DRIVER ) or die (odbc_errormsg(). "Error");
Also have this extension:
extension=php_sqlsrv_52_nts_vc6.dll
extension=php_pdo_sqlsrv_52_nts_vc6.dll
I read to uncomment (php.ini) line with code php_odbc.dll, but i don't have these line and file.
Any tips to help?
Thank you!
I have the IIS and xampp installed and the problem is the environment variables.
I changed the path C:\xampp\php to C:\php and now, works like expected.

phpredis: got error when running script Call to undefined function new Redis()

env:
CentOS 6.5
php5.5.3 / php-fpm5.5.3
nginx 1.0.15
php-redis 2.2.8
also added extension_dir and extension settings in php.ini
then restart the service of php-fpm & nginx
and i have confirmed the redis has been enabled/loaded in phpinfo()
step:
i'm trying to run the php script like this
<?php
$redis = new Redis();
?>
got error:
PHP Fatal error: Call to undefined function  new Redis() in /home/html/test1.php on line 2
but when i'm trying to run the same command in php Interactive shell mode, it works well.
why?
update:
i have test a script like this:
print_r(get_loaded_extensions());
then i got already loaded extension redis
if(class_exists('Redis')){
echo 'Redis loaded';
$redis = new Redis();
}else{
echo 'not function Redis';
}
it shows class Redis exist but still get error
[root#i1 html]# php -f test1.php
Redis loadedPHP Fatal error: Call to undefined function new Redis() in /home/html/test1.php on line 16
add dl("redis.so"); and the output:
PHP Warning: Module 'redis' already loaded in Unknown on line 0
Redis loadedPHP Fatal error: Call to undefined function  new Redis() in /home/html/test1.php on line 18
finally, i cant config to use the phpredis plugin.
predis is the better choice in this case.

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.

Categories