getting "1" in my temp.xml when using fwrite

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alexus

    getting "1" in my temp.xml when using fwrite

    fwrite(fopen('t emp.xml','w+'),
    print_r(simplex ml_load_string( curl_exec($test ))),true);

    i for some reason get "1" inside of my temp.xml
  • Erwin Moller

    #2
    Re: getting "1&quot ; in my temp.xml when using fwrite

    alexus schreef:
    fwrite(fopen('t emp.xml','w+'),
    print_r(simplex ml_load_string( curl_exec($test ))),true);
    >
    i for some reason get "1" inside of my temp.xml
    Hi Alexus,
    You are making a mess of thing in more than 1 way.
    First you try to write your code in 1 line, making it hard to follow
    (for you too appearantly).
    Second: You use print_r() in a very strange way.
    Third: You don't close your filehandles.


    Why don't you open an handle first? How will you close this stream?
    And what does that last true mean?
    Read here:

    The third argument is the length, not a boolean.

    Try this:

    $myHandle = fopen('temp.xml ','w+');
    $myData = simplexml_load_ string(curl_exe c($test));
    echo "Going to write:<pre>";
    print_r($myData );
    echo "</pre>";
    fwrite($myHandl e ,$myData);
    fclose($myHandl e);


    Regards,
    Erwin Moller

    --
    "There are two ways of constructing a software design: One way is to
    make it so simple that there are obviously no deficiencies, and the
    other way is to make it so complicated that there are no obvious
    deficiencies. The first method is far more difficult."
    -- C.A.R. Hoare

    Comment

    • Jerry Stuckle

      #3
      Re: getting &quot;1&quot ; in my temp.xml when using fwrite

      alexus wrote:
      fwrite(fopen('t emp.xml','w+'),
      print_r(simplex ml_load_string( curl_exec($test ))),true);
      >
      i for some reason get "1" inside of my temp.xml
      simplexml doesn't cooperate with print_r() or var_dump().

      Instead of doing all this in one statement, first fetch the string with
      curl_exec() and ensure it worked OK. Then call simplexml_load_ string().

      Rather than using print_r(), iterate through the child elements. See
      http://www.php.net/manual/en/functio...t-children.php for
      an example on how to iterate the child nodes.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...