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

Home » General » PHP discussions » strange behaviour - fwrite
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
strange behaviour - fwrite [message #27585] Tue, 13 September 2005 12:47 Go to next message
!alex is currently offline  !alex   Germany
Messages: 23
Registered: February 2004
Location: germany
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 05:05 Go to previous message
richardlynch is currently offline  richardlynch   United States
Messages: 8
Registered: April 2006
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
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: Mon Dec 11 14:19:06 EST 2017

Total time taken to generate the page: 0.00635 seconds