[PHP] require() causing strange characters ?

2009-02-05 Thread cr.vegelin
Hi all,

I have a script called test.php:
?php echo C; require(echo.php); echo D; ?

and a script called echo.php:
?php echo test; ?

With IE and Firefox it shows: CtestD
but when I view the source, it seems to be: C�testD

When debugging it, it seems that:
 CtestD   has length 9 in stead of 6
 pos1has char=C ord=67 
 pos2has char=� ord=239 
 pos3has char=� ord=187 
 pos4has char=� ord=191 
 rest okay ...

Any idea what's causing this and how to solve it ?

TIA, Cor


Re: [PHP] require() causing strange characters ?

2009-02-05 Thread Paul M Foster
On Fri, Feb 06, 2009 at 06:34:41AM +0100, cr.vege...@gmail.com wrote:

 Hi all,
 
 I have a script called test.php:
 ?php echo C; require(echo.php); echo D; ?
 
 and a script called echo.php:
 ?php echo test; ?
 
 With IE and Firefox it shows: CtestD
 but when I view the source, it seems to be: C??testD
 
 When debugging it, it seems that:
  C???testD   has length 9 in stead of 6
  pos1  has char=C ord=67 
  pos2  has char=??? ord=239 
  pos3  has char=??? ord=187 
  pos4  has char=??? ord=191 
  rest okay ...
 
 Any idea what's causing this and how to solve it ?

I don't know about the odd characters. You might try include() instead
of require() and see if the behavior changes.

I've noticed that Apache tends to insert an unpredictable number of
spaces in code when PHP is embedded in the HTML. My best guess is that
Apache substitutes blanks for all the non-printing PHP code in the file.
But that's just a guess.

How exactly are you managing to obtain the page in such a way that you
can test character codes and such?

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php