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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:01:50+00:00 2026-06-09T03:01:50+00:00

This will be a newbie question but I’m learning php for one sole purpose

  • 0

This will be a newbie question but I’m learning php for one sole purpose (atm) to implement a solution–everything i’ve learned about php was learned in the last 18 hours.

The goal is adding indirection to my javascript get requests to allow for cross-domain accesses of another website. I also don’t wish to throttle said website and want to put safeguards in place. I can’t rely on them being in javascript because that can’t account for other peers sending their requests.

So right now I have the following makeshift code, without any throttling measures:

<?php

  $expires = 15;

  if(!$_GET["target"])
    exit();
  $fn = md5($_GET["target"]);
  if(!$_GET["cache"]) {
    if(!array_search($fn, scandir("cache/")) ||
      time() - filemtime($file) > $expires)
      echo file_get_contents("cache/".$fn);
    else
      echo file_get_contents(file);
  }
  else if($_GET["data"]) {
    file_put_contents("cache/".$fn, $_GET["data"]);
  }
?>

It works perfectly, as far as I can tell (doesn’t account for the improbable checksum clash). Now what I want to know is, and what my search queries in google refuse to procure for me, is how php actually launches and when it ends.

Obviously if I was running my own web server I’d have a bit more insight into this: I’m not, I have no shell access either.

Basically I’m trying to figure out whether I can control for when the script ends in the code, and whether every ‘get’ request to the php file would launch a new instance of the script or whether it can ‘wake up’ the same script. The reason being I wish to track whether, say, it already sent a request to ‘target’ within the last n milliseconds, and it seems a bit wasteful to dump the value to a savefile and then recover it, over and over, for something that doesn’t need to be kept in memory for very long.

  • 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-09T03:01:53+00:00Added an answer on June 9, 2026 at 3:01 am

    Every HTTP request starts a new instance of the interpreter; it’s basically an implementation detail whether this is a whole new process, or a reuse of an existing one.

    This generally pushes you towards good simple and scalable designs: you can run multiple server processes and threads and you won’t get varying behaviour depending whether the request goes back to the same instance or not.

    Loading a recently-touched file will be very fast on Linux, since it will come right from the cache. Don’t worry about it.

    Do worry about the fact that by directly appending request parameters to the path you have a serious security hole: people can get data=../../../etc/passwd and so on. Read http://www.php.net/manual/en/security.variables.php and so on. (In this particular example you’re hashing the inputs before putting them in the path so it’s not a practical problem but it is something to watch for.)

    More generally, if you want to hold a cache across multiple requests the typical thing these days is to use memcached.

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

Sidebar

Related Questions

This question will sound like a newbie but i have gone through all threads
I apologize for this newbie question, but I'm looking for a simple solution. I
it might be a newbie question, but does this PHP 5.4 feature Added class
I'm absolutely sure this will be a trivial, newbie question, but hey - what's
This is a very newbie question and i will probably get downvoted for it,
This will be probable quite odd question. But i thought I will give it
This will probably be a bot of a waffly question but ill try my
This is a total newbie question, but I wonder if someone could assist with
First : Appologize for my bad english. Sorry for this newbie software question, but
This is a brain-dead newbie question, but here goes: What determines what files get

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.