Entry
Call to undefined function
Nov 8th, 2004 16:01
Philip Olson, Dennis Boyle,
Many PHP functions are optional and not compiled into PHP by default.
When you (or your sysadmin) compiles PHP, configure options are passed
in that determine which PHP functions (extensions) will be available.
For example:
./configure --with-mysql --enable-ftp
That configure line will include MySQL functions, and FTP functions, and
all default functions, into the PHP. Other functions, such as pgsql,
socket, pcntl, etc. will be "undefined" as they won't be compiled in.
To see which modules exist (hence what functions will be available), and
what the configure line was, make a call to the phpinfo() function as it
lists tons of useful PHP information:
<?php phpinfo(); ?>
In short: If you call a legitimate PHP function, and it's undefined,
it's because PHP was not compiled with the appropriate PHP extension/module.
If you're unsure which extension a function belongs to, search the PHP
manual. Let's use MySQL as an example. If mysql-connect is undefined go
here:
http://php.net/mysql-connect
You'll then notice it's a MySQL function as it's in reference to the
MySQL section, so, you'll then go to the MySQL page:
http://php.net/ref.mysql
The instructions tell you how to install MySQL. In Windows it's simpler
to install extensions as they require various DLL's while on other
operating systems, such as Linux, it's done at compile time (see also
dl()). See also the manual page for each extension as they provide
specifics.