Home > front end >  Why cant i see file_get_contents request in firefox and chrome dev tools under network activity?
Why cant i see file_get_contents request in firefox and chrome dev tools under network activity?

Time:11-11

I have 2 files. index.php and form.php

index.php

<?php
echo "123"
?>

form.php

<?php
$result = file_get_contents('http://localhost/fatsecret/index.php');
var_dump($result);
?>

i can see result "123" in form.php. But when i go to dev-tools - network i cant see any request to index.php. Why? this doesnt show in firefox and chrome dev tools.

CodePudding user response:

It's simply because the request to http://localhost/fatsecret/index.php is not coming from your browser.

The request is going directly from your PHP code - which is running on your server - to the localhost server (in this case I assume it's actually the same server, but that's not relevant) which hosts the index.php file. The network path for that request is from one server to another. The browser is not involved in that.

The flow goes like this:

browser -> form.php -> index.php

The browser can only see the first step (browser -> form.php). It does not know what form.php is doing in the background while it's being executed. It simply waits for form.php to return some data. It does not know (or care) how form.php got hold of that data.


In summary:

The browser only sends a request to form.php. The request to index.php does not come from the browser, therefore the browser cannot log or monitor it.

  • Related