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

  • Home
  • SEARCH
  • 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 984783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:04:00+00:00 2026-05-16T05:04:00+00:00

There is a php file ( current.php ) with some variables, like: function do()

  • 0

There is a php file (current.php) with some variables, like:

function do() {
    $var = 'something';
}

And one more php file (retrieve.php), which is loaded to current.php with jQuery ajax .load().

The problem is – retrieve.php doesn’t see $var.

Tryed this (inside retrieve.php, shows nothing):

global $var;
echo $var;

How to fix?

Thanks.

  • 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-16T05:04:00+00:00Added an answer on May 16, 2026 at 5:04 am

    Some things you must be aware of:

    • When you use PHP, you do not download a file: you execute a script and retrieve its output.
    • PHP variables are destroyed when the script ends. You cannot share variables between two scripts unless you store them somewhere (e.g., in a database or session file).
    • PHP variables are local to the function where you define them, unless you issue a global $foo; statement inside the function.
    • jQuery is a JavaScript library. JavaScript and PHP are different languages: they cannot see each other variables.

    Said that, I suggest you reconsider your question and try to explain what you need to accomplish rather that how you want to implement it.

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

Sidebar

Related Questions

Is there any special function to parse a .conf file in php like parse_ini_file()
In wordpress, I have the loop.php file. There I can see the 'read more'
In header.php, is there some way to detect and alert which template is displaying
Is there any way to include php file using require and calling a php
Is there any reflection/introspection/magic in PHP that will let you find the PHP file
Is there any PHP script to convert XML file to DTD. I tried a
Is there any way to remove the contents of an file in php, do
Is there a way to generate a PHP Soap Client from a WSDL file?
Is there a maximum length for the URI in the file_get_contents() function in PHP?
I tried to include a file in another directory using php. There are two

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.