PHP 5.2.8 Memory leak causing empty file HELP! Please!

Discussion in 'PHP' started by Blasingame, May 11, 2009.

  1. #1
    Problem

    $str = file_get_contents('$filename');

    When the $str search process starts on the '$filename' the file returns empty. I'm trying to search a .xml file.

    I think there is a leak maybe because it is an .xml file and maybe another type file would work? Maybe if I convert this file to cvs it would work. Does anyone have any idea where I can or how I can convert this file to try it?

    This may not work i'm just guessing.

    If you have any knowlege of this problem please let me know.
     
    Blasingame, May 11, 2009 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Get rid of the single quotes around $filename and try again. That's a problem...
     
    TwistMyArm, May 11, 2009 IP
  3. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Try removing quotes. E.g.:

    $str = file_get_contents($filename);
    PHP:
    Regards,
    Dennis M.
     
    Dennis M., May 11, 2009 IP
  4. Blasingame

    Blasingame Peon

    Messages:
    761
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    did that and now it runs out of memory
     
    Blasingame, May 11, 2009 IP
  5. monster64

    monster64 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How big is the file you are trying to open?
     
    monster64, May 11, 2009 IP
  6. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    maybe try fopen instead of file_get_contents()

    For example
    
    	$fd = fopen ($filename, "r");
    	$contents = fread ($fd,filesize ($filename));
    	fclose ($fd); 
    
    PHP:
    Might handle memory better, but I'd be curious to know how big the file is.
     
    kblessinggr, May 11, 2009 IP
  7. Blasingame

    Blasingame Peon

    Messages:
    761
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7

    The file is 23 MG
     
    Blasingame, May 11, 2009 IP