When i use Simplexml_load_file, how can i close or end the load file process?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cudan706
    New Member
    • May 2010
    • 2

    #1

    When i use Simplexml_load_file, how can i close or end the load file process?

    When i use Simplexml_load_ file. How can i close or end load file process xml when simplexml_load_ file.
    example:
    Code:
    <?php
    $xml = simplexml_load_file("path_to_xml");
    foreach()
    {
      //example code
    }
    
    //this here, please help me close simplexml_load_file() process.
    ?>
    My shared hosting is linux system, it's slow and very weak. So my site has 50 visitor, it's die. Pls help me.
    Last edited by Atli; May 4 '10, 06:38 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    The simplexml_load_ file function returns an instance of the SimpleXMLElemen t class. To "close" the instance, you simply remove all references to it, thus allowing the garbage collection process to clean it up.
    [code=php]<?php
    // Create an instance.
    $instance = simplexml_load_ file('/path/to/file.xml');

    // And once you are done with it, simply do:
    $instance = null;

    // Now the instance can be cleaned up by the
    // garbage collector.
    ?>[/code]
    Note, however, that unless there is something happening after you remove the reference to it, you are unlikely to see a performance gain. PHP automatically cleans up after itself when the script ends.

    Comment

    • cudan706
      New Member
      • May 2010
      • 2

      #3
      thanks so much, i'll try.

      Comment

      Working...