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 7616865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:59:44+00:00 2026-05-31T02:59:44+00:00

I’m making a PHP class that handles some traffic with the use of CURL

  • 0

I’m making a PHP class that handles some traffic with the use of CURL and everything works quite well (except for cookies but hey that’s another thing). One thing that doesn’t work that great is the curl_close() function though and I have no idea why…

$curlSession = &$tamperCurl->getCURLSession();

var_dump($curlSession);
curl_close($curlSession);
die();

I previously called curl_exec() and everything worked perfectly. The output this is giving me is:
resource(6) of type (curl)

Warning: curl_close(): 6 is not a valid cURL handle resource in
filename.php on line 58

Does anybody have any idea why this is happening? (the var_dump is saying that it’s obviously a curl session).

ADDITION:

Because of copyright problems I cannot post the whole TamperData class atm (it will be GPL later).

I have simplified it to this:

$tamperCurl = new TamperCurl('test.xml');
echo var_dump($tamperCurl->getCURLSession());
curl_close($tamperCurl->getCURLSession());
die();

The constructor of TamperCurl is like this:

public function __construct($xmlFilePath, $options=null)    
{
    if($options != null) $this->setOptions($options);

    $this->headerCounter = 0;
    $this->setXMLHeader($xmlFilePath);
    $this->init();
}

public function init($reuseConnection=false,$resetSettings=null)
{
    $this->curlSession = curl_init();
}

Again the same output:
resource(8) of type (curl)
PHP Warning: curl_close(): 8 is not a valid cURL handle resource in TamperCurl.php on line 58

  • 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-31T02:59:46+00:00Added an answer on May 31, 2026 at 2:59 am

    Eventually the problem turned out to be this:

    public function __destruct()
    {
        if($this->curlSession != null) curl_close($this->curlSession);
    }
    

    If you have already closed the curlSession, the variable containing the resource isn’t set to NULL but it’s set to ‘unknown type’. So this fixes the problem:

    public function __destruct()
    {
        if(gettype($this->curlSession) == 'resource') curl_close($this->curlSession);
    }
    

    I’m not sure why but this also fixed my problem with cookies, so it might be that if you try to close an already closed curl session something else goes wrong.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.