Writing integers to a file with PHP 4

Discussion in 'OT Technology' started by Pudifin, Dec 14, 2005.

  1. Pudifin

    Pudifin These girls > olsen twins

    Joined:
    May 2, 2002
    Messages:
    3,252
    Likes Received:
    0
    What is the command to write integers to a file with PHP 4? I tried fwrite but that doesn't seem to work, even when using strval() to convert to a string. fprintf() is not supported until PHP 5 and I can't seem to find a function that works. I tried using PHP 5 but then fscanf() doesn't seem to work so I'd have to change a bunch of code, although I haven't played around with PHP 5 much yet. Any help would be great.
     
  2. CrackaLackaZe

    CrackaLackaZe New Member

    Joined:
    Nov 4, 2003
    Messages:
    199
    Likes Received:
    0
    Location:
    Gainesville, FL
    data types are loosely defined in PHP, there's no difference in syntax between writing a char and an int.

    $target = fopen($fileName, 'a'); //the a is a mode, check php.net/fopen for other modes
    $content = 2; //or some string
    fwrite($target, $content);
    fclose($target);
     

Share This Page