FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » strange behaviour - fwrite
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
strange behaviour - fwrite [message #27585] Tue, 13 September 2005 16:47 Go to next message
!alex is currently offline  !alex   Germany
Messages: 23
Registered: February 2004
Location: germany
Karma: 0
Junior Member
Hi,

i found some strange behaviour with this piece of code:
(btw: should write a xml-playlist for a flash mp3-player)

echo $songs;
if (strlen($songs) ==0) echo 'strlen: 0';
fwrite($h,strlen($songs).'
</Playlist></XML>');
fclose($h);


$songs is a string built previously in a foreach-loop,
when i print $songs to screen the output is like expected:

<Song>
      <Name>Reach for the Moon</Name>
      <Src>/elements/mp3/1/1/pre/NQ==.mp3</Src>
      <Artist></Artist>
      </Song>
[....]


The strange thing is that as strlen($songs) 0 (!!!) is written to the file.

I tired to write the string to the file several times, used fiel_put_contents and whatever with no success...

For me it looks like php has 2 different views to the value of $songs ?!

Any ideas how to write the string's content (as displayed by echo) to the file would be great.

Setup is:
Apache/1.3.33 (Unix) PHP/5.0.5 mod_ssl/2.8.22 OpenSSL/0.9.7a
, zend_optimizer.version=2.5.10a


I wouldn't wonder if this is a bug in php (or maybe also the zend-optimizer) ... i made an upgrade to php 5.0.5 ten minutes ago - no success :/

Alex
Re: strange behaviour - fwrite [message #31406 is a reply to message #27585] Fri, 21 April 2006 09:05 Go to previous message
richardlynch is currently offline  richardlynch   United States
Messages: 8
Registered: April 2006
Karma: 0
Junior Member
You need to copy/paste the code your are using.

Not all of it, but the fwrite part, and if the building of $songs is short, that part.

Because almost-for-sure you've made a silly typo in the variable name or something equally simple.

The odds that this is an actual bug in PHP are about a trillion to one against.

There would be a million posts about it if this didn't work right.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Some clients receive Registration email, Some don't?
Next Topic: Undefined Index Troubles... [Help Please]
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Dec 26 20:30:20 GMT 2024

Total time taken to generate the page: 0.02266 seconds