Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:12:07+00:00 2026-06-11T21:12:07+00:00

I am reading one Persian text file (using PHP) with the help of below

  • 0

I am reading one Persian text file (using PHP) with the help of below code:

/* Reading the file name and the book (UTF-8) */
if(file_exists($SourceDirectoryFile))
{
        $NameBook  = "name.txt";
        $AboutBook = "about.txt";

        $myFile = "Computer-Technolgy/2 ($i)/".$NameBook;
        $fh = fopen($myFile, 'r');
        $theData = fread($fh, filesize($myFile));
        fclose($fh);
        echo 'Name file: '. $theData.'<hr/>';
}

name.txt file contents :

آموزش شبكه هاي کامپيوتري (LEARNING NETWORK)

Name file: ����� ���� ��� ��������� (LEARNING NETWORK)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:12:08+00:00Added an answer on June 11, 2026 at 9:12 pm

    The reason you are seeing this is because you are just echoing the contents raw. Your browser will need more information, in order to display the message in its correct form.

    The easiest way is to use the snippet below.

    /* Reading the file name and the book (UTF-8) */
    if (file_exists($SourceDirectoryFile))
    {
    
        $NameBook  = "name.txt";
        $AboutBook = "about.txt";
    
        // Using file_get_contents instead. Less code
        $myFile   = "Computer-Technolgy/2 ($i)/" . $NameBook;
        $contents = file_get_contents($myFile);
    
        // I want my browser to display UTF-8 characters
        header('Content-Type: text/html; charset=UTF-8');
        echo 'Name file: ' .  $contents . '<hr/>';
    }
    

    Please note that the header function needs to be executed at the beginning of the output to the browser. So for instance if you have additional data that is displayed prior to this function, you need to move the header statement at the top. Otherwise you will end up with warnings on screen that the headers have already been set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading one Chinese text file (used PHP) with the help of below
I am reading one file using ruby in which I have written regexp in
I am using Microsoft.Office.Interop.Excel in a winform where I am reading one excel file,
I'm having problems reading this one JPEG file using ImageIO.read(File file) - it throws
I have one process who's reading from a file (using file.read() ) and one
Hello all i am reading one xlsx file using XSSF of Apche POI .
using php, if possible. What does it mean? I was reading one of my
I am reading one property file which contains some file paths using shell script.
I am reading one file using Ruby and I am able to filter out
Hey all. I'm reading from one sql-format file to another, and two bytes in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.