Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 769623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:22:00+00:00 2026-05-14T18:22:00+00:00

Is there something simpler than the following. I am trying to make a GET

  • 0

Is there something simpler than the following.

I am trying to make a GET request to a PHP script and then exit the current script.

I think this is a job for CURL but is there something simpler as I don’t want to really worry about enabling the CURL php extension?

In addition, will the below start the PHP script and then just come back and not wait for it to finish?

//set GET variables
$url = 'http://domain.com/get-post.php';

$fields = array(
    'lname'=>urlencode($last_name),
    'fname'=>urlencode($first_name)
    );

//url-ify the data for the GET
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_GET,count($fields));
curl_setopt($ch,CURLOPT_GETFIELDS,$fields_string);

//execute GET
$result = curl_exec($ch);

//close connection
curl_close($ch);

I want to run the other script which contains functions when a condition is met so a simple include won’t work as the if condition wraps around the functions, right?

Please note, I am on windows machine and the code I am writing will only be used on a Windows OS.

Thanks all for any help and advice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:22:01+00:00Added an answer on May 14, 2026 at 6:22 pm
    $url = 'http://domain.com/get-post.php?lname=' . urlencode($last_name) . '&fname=' . urlencode($first_name);
    $html = file_get_contents($url);
    

    If you want to use the query string assembly method (from the code you posted):

    //set GET variables
    $url = 'http://domain.com/get-post.php';
    
    $fields = array(
        'lname'=>urlencode($last_name),
        'fname'=>urlencode($first_name)
        );
    
    //url-ify the data for the GET
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');
    $html = file_get_contents($url . '?' . $fields_string);
    

    See:
    http://php.net/manual/en/function.file-get-contents.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way in Ruby to get a true/false value from something
Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string
Is there something like the following in Apache Common Lang or Spring Utils or
I thought what I wanted would be pretty simple, but there must be something
Is there a simple way to see assigned shortcuts with given prefix? Something similar
Is there something in EF 4.1 that allows for a reconnect to a database
Is there something new about row-level security in SQL Server 2012? In 2008 and
Is there something equivalent to OmniCppComplete for java in vim ? I know of
Is there something akin to the .NET xsd.exe for java - generating classes from
Is there something like die in JavaScript? I've tried with break, but doesn't work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.