Z
Z
zumore2020-05-21 05:55:08
PHP
zumore, 2020-05-21 05:55:08

How to insert variable in file_get_contents?

Hello, I can't insert a variable into file_get_contents. I've tried

various options, such as depletion, inserting various variables, but nothing helps. This function does not want to take a variable into account.

When the page is loaded, the balance is shown, but when you click on the 'Update' button, it gives an error, the link is written without a token in the variable Update.php

file :

$info = file_get_contents('https://******/api/balance/get?api_token='.$_SESSION['z']['token']);
$info = json_decode($info, true);
echo 'Баланс: <span style="color:yellowgreen">'.$info[data][balance].'</span> | <span style="color:darkred">'.$info[data][frozen].'</span>';
print_r($_SESSION['z']['token']);

Attaching a file in the main directive
<div id="up" style="margin: 0 5px"><?php include "include/update.php" ?></div>
    <button id="upClick" class="whiteButton">Обновить</button>
<script type="text/javascript">
    $("#upClick").click(function(e){
        e.preventDefault();
        $("#up").load('include/update.php');
    });
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-05-21
@galaxy

Who puts the cookie? If it is not placed in the root of the site (/), you need to prescribe path


path
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set i

https://www.php.net/manual/en/function.setcookie.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question