Share a variable between two php files on two different serv
Moderator: General Moderators
-
Proqrammer
- Forum Newbie
- Posts: 10
- Joined: Mon Nov 13, 2006 5:37 am
Share a variable between two php files on two different serv
Is there anyway to share a variable lets say an array between two php pages on two different servers?
-
Proqrammer
- Forum Newbie
- Posts: 10
- Joined: Mon Nov 13, 2006 5:37 am
Thanks for your reply Volka,
Let's say I have a php page named "page1.php" hosted on "www.somesite1.com/page1.php"
In this php page I have declared a string variable such as $string1="foo";
Now there is another php page named "page2.php" hosted on another server at "www.somesite2.com/page2.php"
Now is there any built in function or method to have the value of string1 in page2.php ?
Let's say I have a php page named "page1.php" hosted on "www.somesite1.com/page1.php"
In this php page I have declared a string variable such as $string1="foo";
Now there is another php page named "page2.php" hosted on another server at "www.somesite2.com/page2.php"
Now is there any built in function or method to have the value of string1 in page2.php ?
Insert information into database and remotely connect?
Insert information into text file and read from different server?
Secondary server calling on a script directly for results in say XML/tab separated format?
This sort of thing is easily possible, but what you should do is identify whether or not your application is designed optimally because cross-server data exchanges can be costly for script processing time if the application is heavily reliant on this data.
If you feel there is no other way to have the system setup, whatever the system may be, then look into implementing one of the above ways. I'd pick based around what's best for my needs and what's optimal for security and loading times.
By the way, how often is this data updated? Do you want this exchange happening on a schedule in the background or do you want it happening at script run-time when a user is on the site? Can you give an example as to what the data is?
The more information you provide in your problem scenarios the much better it is for the people helping you find a suitable solution, as volka hinted at.
Insert information into text file and read from different server?
Secondary server calling on a script directly for results in say XML/tab separated format?
This sort of thing is easily possible, but what you should do is identify whether or not your application is designed optimally because cross-server data exchanges can be costly for script processing time if the application is heavily reliant on this data.
If you feel there is no other way to have the system setup, whatever the system may be, then look into implementing one of the above ways. I'd pick based around what's best for my needs and what's optimal for security and loading times.
By the way, how often is this data updated? Do you want this exchange happening on a schedule in the background or do you want it happening at script run-time when a user is on the site? Can you give an example as to what the data is?
The more information you provide in your problem scenarios the much better it is for the people helping you find a suitable solution, as volka hinted at.
-
Proqrammer
- Forum Newbie
- Posts: 10
- Joined: Mon Nov 13, 2006 5:37 am
-
Proqrammer
- Forum Newbie
- Posts: 10
- Joined: Mon Nov 13, 2006 5:37 am
-
Proqrammer
- Forum Newbie
- Posts: 10
- Joined: Mon Nov 13, 2006 5:37 am
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Yes, but then again not really for just a single value. If it's a scalar value (i.e. a number or a string) then just dump out the value. If it's an array you could of course dump out the serialized string and unserialize() it from the other server.Proqrammer wrote:Someone has told me I should use an include file with serialized data! does that make sense?
Look at file_get_contents() but you'll need allow_url_fopen in php.ini for it to work remotely.
http://www.php.net/serialize
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA