Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP 'file' problem

  • 31-03-2009 11:42AM
    #1
    Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭


    running php 4.x

    trying to retrieve data returned by a url using 'file' but doesnt seem to work at all?

    also tried simple
    [PHP]
    $url = "http://www.google.com";
    $html = file_get_contents(urlencode($url)) or die("Can't open url");
    echo $html; [/PHP]

    no joy.


Comments

  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    looks like hosting365 have blocked it for security purposes.
    Using curl instead

    [PHP]<?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://example.com/");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
    ?>[/PHP]


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    This was a massive secuity flaw in PHP for years; it's handy if you need it but it's a huge hole if it's not required and scripts aren't set up to recognise abuse.

    They finally disabled it by default in PHP 5.


Advertisement