H
H
hamburger222015-10-12 13:12:19
PHP
hamburger22, 2015-10-12 13:12:19

how to change string encoding in php?

Hello.
There is a php page. Text is written on it, for example the word "Hello"
It is necessary that any text that is written on the page in Cyrillic is automatically encoded in windows1251
The word Hello will look like this: =?windows-1251?B?z/Do4uXy?=
Suggestion: Hello . How are you? looks like this: =?windows-1251?B?z/Do4uXyLiDK4Oog5OXr4D8=?=
Also, I don’t understand how to then take a certain part of the page with encoded text and insert it into another php page (the include function inserts the entire page, but how to insert only a part?)
I rummaged through everything I can, but I can’t find anything. Thanks in advance for your replies

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grand Silence, 2015-10-12
@mixtape774

take a specific part of a page with encoded text and paste in another php page

Put it in a separate file (then the usual include) or a function (just don't forget to call it).
// error.php
echo 'Error 404';
// index.php или любой другой .php
include 'error.php';

or
// api.php
function printError() {
echo 'Error 404';
}
// index.php или любой другой .php
include 'api.php'; // или requere, разницу см. на php.net
printError(); // любые функции из файла

----
And it's easier with encoding, google base64.
As I understand it, you are trying to work with mail, maybe this code will help:
$to = "=?windows-1251?B?" . base64_encode($_POST["username"]) . "?= <" . $_POST["mail"] . ">";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question