Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 13th, 2016, 11:48 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to set php variable value from external site

I am a PHP novice and would appreciate some advice on how to achieve the following.

At hypothetical location "no_name_site.com/.count", the file .count contains a numeric string only, for example, 123. The content constantly increments. I want to display the current count at my own web page.

Something like this:


<html>
<?php
$foreign_count = {the current value stored at "no_name_site.com/.count"}
?>
<body>
<center>
<h1>Foreign Site Count</h1>
<p>count = <?php echo $foreign_count; ?></p>
</center>
</body>
</html>

Is this possible in PHP ?
Reply With Quote
  #2 (permalink)  
Old February 14th, 2016, 04:32 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution

I found the answer on StackOverflow by searching for a slightly different title, "how to set php variable value from external domain".

<?php
$foreign_count = file_get_contents('http://no_name_site.com/.count');
?>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable not set or With Block not set brucechess BOOK: Beginning VB.NET Databases 1 March 3rd, 2009 06:30 AM
Object variable or With block variable not set I_Chappers ASP.NET 2.0 Basics 3 June 26th, 2008 04:15 PM
php take get variable and dynamically set values crmpicco PHP How-To 1 October 22nd, 2007 07:19 PM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM
External Access to my site pvasudevan HTML Code Clinic 8 March 17th, 2004 05:49 AM



All times are GMT -4. The time now is 04:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.