php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48819 dl function is undefined
Submitted: 2009-07-06 15:50 UTC Modified: 2011-11-11 12:53 UTC
Votes:28
Avg. Score:4.1 ± 1.1
Reproduced:24 of 25 (96.0%)
Same Version:9 (37.5%)
Same OS:8 (33.3%)
From: pkwan at advsofteng dot net Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.0-5.3.3 OS: Multiple
Private report: No CVE-ID: None
 [2009-07-06 15:50 UTC] pkwan at advsofteng dot net
Description:
------------
Using the "dl" function results in a "Call to undefined function dl()" error if the PHP is used with a web server. It is as if the "dl" function does not exist in PHP any more. This has been tested using "php-cgi.exe" VC6 and on IIS on both Windows 2000 and Windows XP, and using "php-cgi.exe" VC9 on IIS on Windows XP.

However, when using "php.exe" or "php-cgi.exe" in a DOS shell interactively, the "dl" function works normally.



Reproduce code:
---------------
<?php dl("any_name.dll"); ?>


Expected result:
----------------
If the DLL is loaded successfully, no message is expected. Otherwise, some meaningful error message is expected. 

Actual result:
--------------
Fatal error: Call to undefined function dl() in C:\Inetpub\Scripts\phpinfo.php on line 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-06 16:07 UTC] dani88elx at gmail dot com
This is not a bug.

dl() is deprecated from 5.3 version
 [2009-07-06 16:24 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2009-07-06 17:32 UTC] pkwan at advsofteng dot net
This is definitely a bug. According to PHP 5.3 documentation, dl should work, at least for CLI, CGI and Embed. Pease read the PHP documentation.

The PHP 5.3 documentation for "dl" says:

This function now throws an E_DEPRECATED notice on all sapi's except for CLI, CGI and Embed. 

Also, the PHP 5.3 change log "http://www.php.net/ChangeLog-5.php" says:

Changed dl() to be disabled by default. Enabled only when explicitly registered by the SAPI. Currently enabled with cli, cgi and embed SAPIs. (Dmitry) 

So the above clearly says dl should work on CLI, CGI and Embed SAPI. I am testing using CGI, and it does not work. Therefore it is a bug.

Furthermore, from the PHP documentation on dl, the E_DEPRECATED is only a "notice", not an error. So dl should work in all other SAPI as well.
 [2010-08-16 17:13 UTC] cynic@php.net
-Status: Bogus +Status: Re-Opened
 [2010-08-16 17:13 UTC] cynic@php.net
this bug is not bogus.  it's either valid or should be reclassified as a documentation bug.  the manual says (as of August 16, 2010):

5.3.0  	 dl() is now disabled in some SAPI's due to stability issues. The only SAPI's that allow dl() are: CLI, CGI and Embed.

in fact, a peek at php-5.3.3/ext/standard/dl.c suggests that the manual is quite misleading as it leaves the reader thinking that dl() will work in non-TS versions of CLI, CGI and Embed just find, when in fact the function is E_DEPRECATED across the board:

	if ((strncmp(sapi_module.name, "cgi", 3) != 0) &&
		(strcmp(sapi_module.name, "cli") != 0) &&
		(strncmp(sapi_module.name, "embed", 5) != 0)
	) {
#ifdef ZTS
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not supported in multithreaded Web servers - use extension=%s in your php.ini", filename);
		RETURN_FALSE;
#else
		php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "dl() is deprecated - use extension=%s in your php.ini", filename);
#endif
	}


that's correct as long as i run php-cgi.exe on the command line:

  var_dump(extension_loaded('sqlsrv'));
  dl('php_sqlsrv.dll');
  var_dump(extension_loaded('sqlsrv'));

run with

  php-cgi -nq -d extension_dir=$somewhere -d error_reporting=-1 test.php

gives

  bool(false)
  bool(true)

however, running the same php-cgi inside Apache 2.2 on Windows, the dl() function does not exist.

tested with 5.3.3-nts-vc9.
 [2011-01-12 18:45 UTC] cipri@php.net
We are currently experiencing the same problem on php-5.3.3. To confuse the matter even more:

We use an Apache/2.2.14 (Debian) server with suexec enable.
* When running the CGI-binary from the command line everything works fine, dl() is available and works as expected.
* When running the CGI-binary through apache2's suexec command everything works.
* The CLI binary also works without any problem.
* Only when running php in CGI/FastCGI mode through Apache's suexec things stop working and php dies with the "Call to undefined function dl()", instead of the expected correct behaviour, or even throwing an error.
 [2011-01-12 18:47 UTC] cipri@php.net
-Operating System: Windows +Operating System: Multiple -PHP Version: 5.3.0 +PHP Version: 5.3.0-5.3.3
 [2011-01-13 12:30 UTC] cipri@php.net
For those still struggling with this problem, we reverted the patch as shown on http://www.mail-archive.com/php-cvs@lists.php.net/msg39628.html and the problem went away. 

IMHO this patch should be reversed, as it says  "Disable dl() in CGI and FastCGI modes" while the website states "The only SAPI's that allow dl() are: [...] CGI"
 [2011-11-11 03:34 UTC] ezyang@php.net
-Status: Re-Opened +Status: Verified
 [2011-11-11 03:34 UTC] ezyang@php.net
Yeah, this is definitely either a documentation bug or a code bug. Have we just decided that dl() is too buggy to want to deal with?
 [2011-11-11 06:53 UTC] pajoye@php.net
-Type: Bug +Type: Documentation Problem
 [2011-11-11 12:53 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=319049
Log: Fix doc bug #48819 (dl function is undefined) and also remove some extraneous
apostrophes that crept in.
 [2011-11-11 12:53 UTC] aharvey@php.net
-Status: Verified +Status: Assigned -Package: Scripting Engine problem +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2011-11-11 12:53 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2011-11-11 12:53 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 15:01:39 2019 UTC