Require_once in PHP is printing on mobile devices

I have a PHP file on my server that works well on desktop devices. This is basically just this piece of code:

<?php
    require_once('wp-load.php');

    global $wpdb;

    $myrows = $wpdb->get_results("SELECT * FROM view_posts_map LIMIT 10");
?>

(The rest of the content prints the results on an HTML page.)

It happens that in desktop browsers everything works fine! But on mobile devices, such as my Motorola 3rd G, all this gets confused, but 'wp-load.php'simply printed in HTML code. This makes no sense, since PHP is handled on the server side and there is no code branch for the request device.

I tested several other mobile devices and the HTML went bad, while on desktop browsers the HTML is clean and displays the content as it should.

To try to find out what is happening, I created an empty file with the following body:

<?php echo 'a'; ?>
<?php include('./wp-load.php'); ?>
<?php echo 'b'; ?>

There is nothing in the file.

On Windows, Google Chrome prints on this page ab, on my Google Chrome device it printsa‹Kùï¾q

+4
source share
1 answer

For some reason, it was a problem with the encoding of the .php file. By creating a new file, copying wp-load.php and changing its contents according to their encoding, everything will work out on both devices.

+3
source

Source: https://habr.com/ru/post/1660712/


All Articles