php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32244 enabled iconv extension but got "undefined function iconv()" error
Submitted: 2005-03-09 07:15 UTC Modified: 2005-03-13 15:25 UTC
From: wellswang at auo dot com Assigned:
Status: Closed Package: ICONV related
PHP Version: 5.0.3 OS: FreeBSD 5.3
Private report: No CVE-ID: None
 [2005-03-09 07:15 UTC] wellswang at auo dot com
Description:
------------
enabled iconv extension but got "undefined function iconv()" error

I build php5.0.3 on my freebsd 5.3 box,
My configure command is:
'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--with-bz2' '--enable-calendar' '--with-zlib' '--enable-ftp' '--with-gd' '--enable-mbstring' '--with-mysql=/usr/local' '--with-mysqli' '--enable-sqlite-utf8' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-spl' '--with-regex=php' '--with-apxs2=/usr/local/sbin/apxs' '--prefix=/usr/local' 'i386-portbld-freebsd5.3' '--with-xmlrpc' '--with-iconv-dir=/usr/local/lib'

It say's configured without error:
.........
checking for iconv support... yes
checking for iconv... (cached) yes
checking if iconv is glibc's... no
checking if iconv supports errno... no
.........
checking whether libxml build works... (cached) yes
checking for XMLRPC-EPI support... yes
checking libexpat dir for XMLRPC-EPI... no
checking iconv dir for XMLRPC-EPI... /usr/local/lib
checking for libiconv in -liconv... (cached) yes
.........

By using php -i or phpinfo() ,i got :

iconv

iconv support => enabled
iconv implementation => unknown
iconv library version => unknown

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

I donot know the meaning of "unknown"
but iconv support is enabled ?!

======================

When I use iconv() in my php program,
I got error message such as :
Fatal error: Call to undefined function iconv() in /http/document/root_osa/classes/blog_function.php on line 683

is it a php bug or my config problem ?

Reproduce code:
---------------
configure command :

'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--with-bz2' '--enable-calendar' '--with-zlib' '--enable-ftp' '--with-gd' '--enable-mbstring' '--with-mysql=/usr/local' '--with-mysqli' '--enable-sqlite-utf8' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-spl' '--with-regex=php' '--with-apxs2=/usr/local/sbin/apxs' '--prefix=/usr/local' 'i386-portbld-freebsd5.3' '--with-xmlrpc' '--with-iconv-dir=/usr/local/lib'


in php file:

<?php
echo iconv("ISO-8859-1", "UTF-8", "This is a test.");
?> 

Expected result:
----------------
This is a test.


Actual result:
--------------
Fatal error: Call to undefined function iconv() in /http/document/root_osa/test.php on line 2


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-09 07:23 UTC] wellswang at auo dot com
i found my problem is same as Bug #12443

but  my php version is 5.0.3 ....
i don't know how to solve it

i use his script to check :
<?php
$exists_iconv_get_encoding = 
function_exists('iconv_get_encoding');
$exists_iconv = function_exists('iconv');

if ($exists_iconv_get_encoding == TRUE) {
	echo "iconv_get_encoding is declared<br>";
} else {
	echo "iconv_get_encoding is not declared<br>";
}

if ($exists_iconv == TRUE) {
	echo "iconv is declared<br>";
} else {
	echo "iconv is not declared<br>";
}

$test_string = "this is an ascii-only test string";
echo "test_string is: $test_string<br>";

$encoding = iconv_get_encoding($test_string);
echo "encoding is: $encoding<br>";

$result = iconv($encoding,'UTF-8',$test_string);
echo "result is: $result<br>";
?>


and  got the same result as Bug #12443:

iconv_get_encoding is declared
iconv is not declared
test_string is: this is an ascii-only test string
encoding is:

Fatal error: Call to undefined function iconv() in /http/document/root_osa/temp/foo.php on line 24
 [2005-03-09 21:54 UTC] tony2001@php.net
Please run this code:
<?php
var_dump(get_extension_funcs("iconv"));
?>
and paste the output here.
 [2005-03-10 01:09 UTC] wellswang at auo dot com
The result is:
--------------------------------------------

array(11) { [0]=>  string(8) "libiconv" [1]=>  string(16) "ob_iconv_handler" [2]=>  string(18) "iconv_get_encoding" [3]=>  string(18) "iconv_set_encoding" [4]=>  string(12) "iconv_strlen" [5]=>  string(12) "iconv_substr" [6]=>  string(12) "iconv_strpos" [7]=>  string(13) "iconv_strrpos" [8]=>  string(17) "iconv_mime_encode" [9]=>  string(17) "iconv_mime_decode" [10]=>  string(25) "iconv_mime_decode_headers" }
 [2005-03-12 14:45 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-03-13 15:25 UTC] wellswang at auo dot com
Thanks,

After i used the latest snapshot of php 5.1.0-dev,
the problem solved.

iconv
iconv support  enabled  
iconv implementation  libiconv  
iconv library version  1.9  

Thanks a lot.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC