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 6668089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:00:09+00:00 2026-05-26T03:00:09+00:00

So, I as I understand, my problem is that file_get_contents() does not send proper

  • 0

So, I as I understand, my problem is that file_get_contents() does not send proper UTF-8 URL even though it’s being passed, so the $_GET data which server is receiving is a bit messed up. Part of my code:

//receiving post data from html form "nacionālā opera"
$q = $_POST["q"];

if (!empty($q)) {
    $get_data = array( 
        'http' => array(
            'header'=> array("Content-Type: text/plain; charset=utf-8",
                             "User-agent: PHP bots;")   
        ) 
    );
    $stream_cont = stream_context_create($get_data);

    $search = str_replace(" ", "+", $q);
    $url = 'http://127.0.0.1/test.php?stotele='.$search.'&a=p.search&t=xml&day=1-5&l=lv';

    if (mb_detect_encoding($url) === 'UTF-8') {
        echo '$url encoding is ok...??';
    } else {
        echo 'URL encoding not UTF-8!';
        exit();
    }

    $rec_data = file_get_contents($url, false, $stream_cont);

Here is what the server gets when printing the $_GET array:

stotele => nacionÄ_lÄ_ opera // this should have been "nacionālā opera", but as u see it got distorted
a => p.search 
t => xml 
day => 1-5 
l => lv 

I hope you understand what I am trying to say. This thing drives me crazy and I can’t solve it, would be nice if someone gave me hints(and yes, my browser encoding is set to UTF-8, also form is sending UTF-8 and if I echo $q or $search or $url I get a normal string, not some messed up symbols.

  • 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-05-26T03:00:09+00:00Added an answer on May 26, 2026 at 3:00 am

    Try using urlencode

    // instead of this:
    // $search = str_replace(" ", "+", $q);
    // use:
    $search = urlencode($q);
    $url = 'http://127.0.0.1/test.php?stotele='.$search.'&a=p.search&t=xml&day=1-5&l=lv';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand the problem that OSGI solved thanks to this question.... What does OSGi
I'm a newbie on Java EE and got a problem that I don't understand
To begin with, let me say that I understand how and why the problem
i dont understand the problem with returning multiple rows: here is my table BBC:
I've been have trouble understand this problem. If I change the variable name fifthViewController
So, I understand the problem of finding the longest simple path in a graph
After some painful experiences, I understand the problem of dangling pointers and double free.
I dont understand what would be the problem with the following code. It needs
I discovered to have some problem to fully understand callbacks scoping when trying to
a funny problem ... i can't understand it.. let me show you what i

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.