O
O
Optimus2014-12-02 09:49:05
PHP
Optimus, 2014-12-02 09:49:05

Creating a file in PHP?

I create a file

$file="html/{$myid[0]['num']}.html";

if(!file_exists($file)) {
$fp = fopen($file, "w"); 
fwrite($fp, "
<html>

<head>
<title>{$myid[0]['title']}</title>
<meta http-equiv=\"Content-type: text/html; charset=UTF-8\">
</head>
    <body>
    {$myid[0]['text']}
    </body>
</html>

");
fclose ($fp);
}

The encoding of the file itself always turns out to be ANSI, how can I make it be created in UTF-8?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2014-12-02
Pyan @marrk2

What is the encoding of the script itself? $myid[0]['text']Where does it come from and in what encoding?
Store everything in utf8 (files, tables in the database) and you will be happy.

I
IceJOKER, 2014-12-02
@IceJOKER

Congratulations =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question