Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2016, 12:48 AM
Registered User
 
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 ?
 
Old February 14th, 2016, 05:32 PM
Registered User
 
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');
?>





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 07: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 06:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.