Writing strings to files

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Writing strings to files

    Dear All,

    I'm fairly new to PHP (i'm converting from Perl) and so I'm still getting up
    the learning curve.

    I'm seeing some odd behaviour when writing certain strings to files.

    The line that is failing is :

    fwrite ($fp,"#include <avr/io.h>\n");

    It only writes the "#include" part. It seems that it is the "<" that is
    causing the problem as the following line works a treat.

    fwrite ($fp,"#include avr/io.h>\n");

    I have even tried writing it using a variable, i.e.

    $myvar = "#include <avr/io.h>";
    fwrite ($fp,"$myvar\n");

    but that doesnt work either.

    So, how do i write the character "<" to a file?

    Any help much appreciated..

    Chris


    Chris Styles Guest

  2. Similar Questions and Discussions

    1. php writing files and permissions
      Hi, I have a php function that uploads images to a directory on my server, I've just changed hosting company and now I get the following error...
    2. writing excel files
      I need to be able to create Microsoft Excel files from a perl script. I want to know which module for doing this that people recommend. I don't need...
    3. Reading and writing files in PHP
      "Marc" <meelzooi2000@yahoo.com> wrote in message news:acad69df.0309010758.2de3fef5@posting.google.com... processing the file (not having written...
    4. Writing to files
      Is there a way to write to a beginning of a file without it overwriting data that's already there or do I have to write to the end of the file in...
    5. [PHP] Writing to files
      Hello, This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 20:37, lines prefixed by '>' were originally written by you. How...
  3. #2

    Default Re: Writing strings to files

    Chris Styles wrote:
    > I'm seeing some odd behaviour when writing certain strings to files.
    >
    > The line that is failing is :
    >
    > fwrite ($fp,"#include <avr/io.h>\n");
    >
    > It only writes the "#include" part. It seems that it is the "<" that
    > is causing the problem as the following line works a treat.
    >
    Are you watching the result with a web browser? In that case <avr/io.h> gets
    treated as a tag and therefore not displayed.

    Look at the source directly, or apply htmlentitities before writing:

    fwrite ($fp, htmlentities("#include <avr/io.h>\n"));


    JW



    Janwillem Borleffs Guest

  4. #3

    Default Re: Writing strings to files

    On Sat, 25 Sep 2004 13:47:21 +0200, "Janwillem Borleffs" <jw@jwscripts.com>
    wrote:
    >Are you watching the result with a web browser? In that case <avr/io.h> gets
    >treated as a tag and therefore not displayed.
    >
    >Look at the source directly, or apply htmlentitities before writing:
    >
    >fwrite ($fp, htmlentities("#include <avr/io.h>\n"));
    ... or sent a Content-type: text/plain header.

    --
    Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
    Andy Hassall Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139