homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Sending information to a server

 10:32 pm on Dec 27, 2013 (gmt 0)

During a plugin's installation there is an option to announce that the website is using the plugin.

If $anncounce=true; a call is made during installation to the plugin's server that includes the website's url. If possible I'd like to improve this code.

if($announce) file_get_contents('http://www.pluginserver.tld/announce/?url='.urlencode($url));

The installation just needs to "ping" the server, it doesn't recieve or use any information from it. Is file_get_contents the best method?

I also don't want to slow down the installation or cause any errors if the server is unresponsive. I just want the script to quickly attempt to report the installation and move on.

Should I use something less strict or stricter than "if($announce)"?




 11:20 pm on Dec 27, 2013 (gmt 0)

if($announce) is fine, but personally, I would not likely use PHP to make the ping, unless there was no other way. What I'd be much more inclined to do instead is use JS and make the ping asynchronous -- I'd even set a "flag" to trigger the JS call/creation via the if($announce) conditional if necessary.


[something like the following, depending on the exact script(s)/situation/application(s)]

if($announce) { $ping=true; }

then later:

if($ping) {
// echo some JS to make an asynchronous request here

[You could probably just move the if($announce) conditional to the correct place in the output and not use two conditionals, but the preceding is merely an example of the "idea" or "theory" I'd work with and not likely the "absolute best" implementation.]


 3:58 pm on Dec 28, 2013 (gmt 0)

Thank you. Unfortunately the only window I have is in this PHP script, although JavaScript would seem ideal.


 8:52 pm on Dec 28, 2013 (gmt 0)

In that case, I'd probably move it to the end of the script and send the info to the browser before making the "ping".


// The PHP that "does stuff" for people to see ends here.


if($announce) {

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved