Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: CURL get PHP

  1. #1
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    United Kindom
    Thanked 136 Times in 136 Posts

    CURL get PHP

    Hi I am just wondering can you do something like this with PHP CURL, I read everything about CURL on php.net but still unsure as I haven't really used CURL before.

    Basicly I want one server to get files from a different server and use them like this.

    sever 1 root
    - folder
    - file.php - contains '$username = "test";'

    server 2 root
    - file.php - contains 'print $username;'

    This will be something similar to what Facebook do for their Application developers, where they read a file that they have given the developer with their codes in and it allows them to search their databases to see if the information is correct etc, can I do this with CURL or not?

    Thank you
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  2. #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Some say it's everything.
    Thanked 397 Times in 390 Posts
    cURL is used to retreive the returned result from visiting a page. It will return a string if you capture the data (rather than just cURL'ing wide open, which will print the string to the page directly). You can read the cURL result to parse it for the data you want, but you can't use it as a method to directly include PHP as your example indicates.

    So, yes - if you parse the cURL's string data before you try to use it. Otherwise, no.

    See this page for the explanation that cURL returns a string:

    Edit: P.S.

    See the eval() function if this ends up being the route you want to go. Beware though, that any malicious script plopped into the target page WILL run on your server.

    Last edited by Rowsdower!; 12-13-2010 at 08:51 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts