我用PHP 7.0開發,我曾嘗試使用的功能函數utf8_encode()和我已經得到了錯誤「調用未定義功能函數utf8_encode()」PHP7.0:調用未定義功能函數utf8_encode()
我不得不嘗試安裝php7.0-XML模塊使用sudo apt-get的安裝php7.0,XML和我得到這個錯誤:如果我讓sudo apt-cache search php7.0-*
我有這樣的結果
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.0-xml : Depends: php7.0-common (= 7.0.18-0ubuntu0.17.04.1)
but 7.0.18-1+deb.sury.org~yakkety+1 is to be installed
E: Unable to correct problems, you have held broken packages.
:
libapache2-mod-php7.0 - lado servidor, lenguaje de guionización HTML-embebido (módulo Apache 2)
php7.0 - Lenguaje de guión empotrado para HTML en el lado del servidor (metapaquete)
php7.0-cgi - Lenguaje de guiones embebidos en HTML para servidores (binario CGI)
php-all-dev - package depending on all supported PHP development packages
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-common - documentation, examples and common module for PHP
php7.0-curl - CURL module for PHP
php7.0-dev - Files for PHP7.0 module development
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mysql - MySQL module for PHP
php7.0-odbc - ODBC module for PHP
php7.0-opcache - Zend OpCache module for PHP
php7.0-pgsql - PostgreSQL module for PHP
php7.0-pspell - pspell module for PHP
php7.0-readline - readline module for PHP
php7.0-recode - recode module for PHP
php7.0-snmp - SNMP module for PHP
php7.0-sqlite3 - SQLite3 module for PHP
php7.0-tidy - tidy module for PHP
php7.0-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.0-xmlrpc - XMLRPC-EPI module for PHP
php-geoip - GeoIP module for PHP
php-xdebug - Xdebug Module for PHP
libphp7.0-embed - HTML-embedded scripting language (Embedded SAPI library)
php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-gearman - PHP wrapper to libgearman
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-gnupg - PHP wrapper around the gpgme library
php-http - PECL HTTP module for PHP Extended HTTP Support
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-libsodium - PHP wrapper for the Sodium cryptographic library
php-mailparse - Email message manipulation for PHP
php-memcache - memcache extension module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-pinba - Pinba module for PHP
php-propro - propro module for PHP
php-ps - ps module for PHP
php-radius - radius client library for PHP
php-raphf - raphf module for PHP
php-redis - PHP extension for interfacing with Redis
php-remctl - PECL module for Kerberos-authenticated command execution
php-rrd - PHP bindings to rrd tool system
php-smbclient - PHP wrapper for libsmbclient
php-solr - PHP extension for communicating with Apache Solr server
php-ssh2 - Bindings for the libssh2 library
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-tideways - Tideways PHP Profiler Extension
php-uploadprogress - file upload progress tracking extension for PHP
php-uuid - PHP UUID extension
php-yac - YAC (Yet Another Cache) for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php-zmq - ZeroMQ messaging bindings for PHP
php7.0-bcmath - Bcmath module for PHP
php7.0-bz2 - bzip2 module for PHP
php7.0-dba - DBA module for PHP
php7.0-enchant - Enchant module for PHP
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.0-imap - IMAP module for PHP
php7.0-interbase - Interbase module for PHP
php7.0-intl - Internationalisation module for PHP
php7.0-mbstring - MBSTRING module for PHP
php7.0-mcrypt - libmcrypt module for PHP
php7.0-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.0-soap - SOAP module for PHP
php7.0-sybase - Sybase module for PHP
php7.0-xsl - XSL module for PHP (dummy)
php7.0-zip - Zip module for PHP
我與Ubuntu的工作和我的版本是:
我能做些什麼來使用函數utf8_encode或utf8_decode的功能呢?
更新1:
我試圖安裝php7.0常見,我已經得到了這樣的結果:
php7.0-common is already in its most recent version
(7.0.18-1+deb.sury.org~yakkety+1).
如何安裝php7.0-XML模塊?
更新2:
我不得不嘗試安裝命令和apt-get安裝php7.0,MBSTRING但我還沒有安裝該模塊。
我不得不嘗試安裝此另一個模塊命令和apt-get安裝php7.0,XMLRPC和我有同樣的結果:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.0-xml : Depends: php7.0-common (= 7.0.18-0ubuntu0.17.04.1)
but 7.0.18-1+deb.sury.org~yakkety+1 is to be installed
E: Unable to correct problems, you have held broken packages.
它不會爲我工作。
更新3: 原設立:網絡在UTF-8和MySQL數據庫編撰,default character set latin
和collate latin1_spanish_ci;
。
從網絡有一個時刻,我們要求一個地址服務器和地址,我們已經得到了特殊字符:
我們將與ID返回行= 2.在「direccion」字段中,我們有這個字符「ü」。服務器對請求沒有編碼地址的響應,我得到:
請求是好的。
但響應:
沒有什麼,沒有任何反應!
現在,我們要編纂地址一樣@duskwuff有建議:
$utf8_text = iconv("ISO-8859-1", "UTF-8", $row["address"])
請求是相同的,但我們已經有了一個應對現在!
如果我們在打印網頁的地址,我們已經有了:
更新4:
下一個測試......我們打算與更新3相同的測試,但更改MySQL數據庫默認字符和整理。我們將數據庫更改爲默認字符UTF8和整理utf8_spanish_ci。我們的網頁仍然使用UTF8編碼,並且服務器的響應沒有編碼地址。
如果我選擇數據庫,我們可以正確地看到所有的數據。
確定。我會提出請求和迴應,但不需要編碼。不要忘記,數據庫中的數據以UTF8格式保存。
請求成功,但請求:
沒有反應,好像在更新3
但是,如果我們編纂與@duskwuff的建議的答覆:
$utf8_text = iconv("ISO-8859-1", "UTF-8", $row["direccion"]);
我們已收到回覆;我們可以看到印在我們頁面上的數據:
因此,我不知道爲什麼,但我必須將數據編纂爲UTF8得到迴應。
我創建模式和表:
CREATE SCHEMA IF NOT EXISTS `31juegos` DEFAULT CHARACTER SET utf8 COLLATE utf8_spanish_ci;
CREATE TABLE IF NOT EXISTS `31juegos`.`tbl006_direccion` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`jugador_id` INT UNSIGNED NOT NULL,
`provincia_id` INT UNSIGNED NOT NULL,
`direccion` VARCHAR(100) NOT NULL,
`ciudad` VARCHAR(50) NOT NULL,
`codigo_postal` VARCHAR(5) NOT NULL,
`pais` VARCHAR(50) NOT NULL,
`telefono` VARCHAR(12) NULL,
`fecha` DATETIME NOT NULL DEFAULT now(),
PRIMARY KEY (`id`),
INDEX `fk_tbl006_direccion_tbl005_jugador1_idx` (`jugador_id` ASC),
INDEX `fk_tbl006_direccion_tbl020_provincia1_idx` (`provincia_id` ASC),
CONSTRAINT `fk_tbl006_direccion_tbl005_jugador1`
FOREIGN KEY (`jugador_id`)
REFERENCES `31juegos`.`tbl005_jugador` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tbl006_direccion_tbl020_provincia1`
FOREIGN KEY (`provincia_id`)
REFERENCES `31juegos`.`tbl020_provincia` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
,我們編纂的領域:
`direccion` VARCHAR(100) NOT NULL,
[utf8_(en | de)code from php7?](http://stackoverflow.com/q/35701730/1415724)和[函數utf8_encode undefined](http://stackoverflow.com/questions/38337444/功能-UTF8編碼-未定義/ 38341255)。你看到那些了嗎? –
從你給我的網址我已經應用了兩種可能的解決方案sudo a2enmod xml2enc和sudo apt-get php-patchwork-urf8它不適用於我:( –
爲什麼你需要它? – zerkms