utf8_(en|de)code removed from php7?
I had the same problem. Just install php7.0-xml
package. Ubuntu 16.04:
sudo apt-get install php7.0-xml
Edit: Restart apache2 to load the new package.
PHP 7 cannot run utf8 functions
It looks like you are installing the wrong version of the xml extension: You seem to be installing the version for php 7.0 and you are using php 7.1.
Try looking for - and installing - php7.1-xmlrpc
and php7.1-xml
.
PHP7.0: Call to undefined function utf8_encode()
Do not use the utf8_encode()
or utf8_decode()
functions. They have misleading names -- they actually perform conversions between ISO-8859-1 and UTF-8. In most situations, they should not be necessary; your database and application should use UTF-8 text throughout, and should never deal with ISO-8859-1 text at all.
If you actually need to convert text from ISO-8859-1 to UTF-8 -- which is what utf8_encode()
does -- use the iconv()
function:
$utf8_text = iconv("ISO-8859-1", "UTF-8", $iso_8859_1_text);
Avoid the utf8_decode()
function entirely. It converts UTF-8 text to ISO-8859-1, and will replace any character which isn't available in ISO-8859-1 with a question mark. This will mangle text written in many European languages, and will make non-Latin text (like Russian or Chinese) completely unreadable.
utf8_encode() and curl_init() not working on PHP7
As per our discussion discussion , below solution comes:-
1.Need to install CURL
on your system by the command :-
sudo apt-get install php7.0-curl
2.Regarding second error i got this link:- utf8_(en|de)code removed from php7?
It states that utf8_encode/decode
is function related to php xml extension
which you have to install your system by below command:-
sudo apt-get install php7.0-xml
Important Note:- after install of these library packages restart your server so that changes will reflect. Thanks.
Call to undefined function utf8_decode
OK so I figured it out. This was related to missing files in /etc/php/7.0/mods-available/
Normally there should be an xml.ini file there but that file was missing because of how I had installed, uninstalled and re-installed PHP. That operation was not done cleanly. After installing PHP from the PPA I had uninstalled it, deleted many files from /etc/php/ (which is not recommended. Use apt-get purge
instead).
So long story short, this worked:
sudo apt-get purge php-xml php7.0-xml
sudo apt-get install php-xml
How can I write a file in UTF-8 format?
file_get_contents() and file_put_contents() will not magically convert encoding.
You have to convert the string explicitly; for example with iconv() or mb_convert_encoding().
Try this:
$data = file_get_contents($npath);
$data = mb_convert_encoding($data, 'UTF-8', 'OLD-ENCODING');
file_put_contents('tempfolder/' . $a, $data);
Or alternatively, with PHP's stream filters:
$fd = fopen($file, 'r');
stream_filter_append($fd, 'convert.iconv.UTF-8/OLD-ENCODING');
stream_copy_to_stream($fd, fopen($output, 'w'));
Wordpress error on 'edit image' and 'add featured image': shows -1 instead of image
The problem was in my php.ini.
The following lines were like this:
variables_order = "GPCS"
request_order = ""
It says that request_order
is OK to be empty as it will, in that case, use the variables_order
directives. But that does not seem to be the case.
variables_order = "GPCS"
request_order = "GP" (GP is the default)
made my server behave correctly and consequently WP now works fine.
Wordpress error on 'edit image' and 'add featured image': shows -1 instead of image
The problem was in my php.ini.
The following lines were like this:
variables_order = "GPCS"
request_order = ""
It says that request_order
is OK to be empty as it will, in that case, use the variables_order
directives. But that does not seem to be the case.
variables_order = "GPCS"
request_order = "GP" (GP is the default)
made my server behave correctly and consequently WP now works fine.
Related Topics
Replacing Variables in a String
How to Send Email with Smtp in PHP
How to Loop Through a Multidimensional Array Without Knowing It's Depth
Get Total Time Difference Between Two Dates Using PHP
How to Serve Mp3 Files with PHP
How to Send a Bytearray (From Flash) and Some Form Data to PHP
How to Show Ajax Loading Gif Animation While the Page Is Loading
Send Checkbox Value in PHP Form
Utf8_(En|De)Code Removed from PHP7
Object of Class Stdclass Could Not Be Converted to String
Retrieving the Last Inserted Ids for Multiple Rows
Assets Not Referencing to Public Folder (Laravel)
Move All Files in a Folder to Another