Re: [PHP] Heredocs, print_r() and newline \n and fnmatch() -curious failures ...

2010-10-09 Thread YAD(YetAnotherDavid)
Thanks for the response - I found the answer to Q1 - the problem of 
formatting newlines - I was running the code outputting to browser - and 
got lazy on some - just pasting the PHP manual examples code directly, 
without bracketing with HTML tags such as pre ... etc. Of course that 
won't produce the formatting I was expecting and as shown in the manual. 
What confused me? - some example code includes the pre HTML tags and 
produce formatted output! So, I feel really stupid about that one. 
Perhaps there is a PHP manual update project in here somewhere to 
normalize the examples code so they can be run to get the output as printed.

---
Q2 re the undefined function - fnmatch() - still needs an explanation. I 
need to get PHP's fnmatch() function, Xdebug, and iMagick's readImage() 
function working in the same setup.


Using Xammplite_Win_32_1.7.1, PHP ver 5.2.9 reports fnmatch() is not a 
defined function and I haven't been able to get Xdebug functioning on 
this setup. readImage() works just fine.


Using Xammp_Win_32_1.7.3, PHP ver 5.3.1 fnmatch() is defined and Xdebug 
works 'out of the box' but Apache crashes when iMagick readImage() is 
called. I think I should communicate this to the extension author. Will 
post here if I get a result.


Thanks again, Peter.
YAD



Peter Lind wrote:

On 23 September 2010 21:47, YAD(YetAnotherDavid) ani...@mail.com wrote:


Question 1 : how to get the newline functioning ? even print_r() output
is not 'newlined' as it should be. Also note the \n is missing between the 
 in the output text of the second test!



Are you outputting to browser or to command line? Browsers have a
habit of ignoring whitespaces, reducing them to one whitespace
character regardless of their type or how many.

Regards
Peter



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



Re: [PHP] Heredocs, print_r() and newline \n and fnmatch() -curious failures ...

2010-09-27 Thread YAD(YetAnotherDavid)

Peter Lind wrote:

On 23 September 2010 21:47, YAD(YetAnotherDavid) ani...@mail.com wrote:

This code is 95% cut and paste from the PHP manual examples -
the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
There are actually two questions here - I have combined the code into one

 ...


Question 1 : how to get the newline functioning ? even print_r() output
is not 'newlined' as it should be. Also note the \n is missing between the 
 in the output text of the second test!



Are you outputting to browser or to command line? Browsers have a
habit of ignoring whitespaces, reducing them to one whitespace
character regardless of their type or how many.

Regards
Peter



Thanks Peter, - output is to browser, I develop in Notepad++ and 
Firefox, and confirm in IE8. But this stuff used to work - I have been 
working with PHP for about two years (not pro) and am used to formatting 
my output for legibility - especially echoing or var_dumping variables 
when still testing the code. So the failure is recent and I just can't 
figure what changed.

David

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



Re: [PHP] Heredocs, print_r() and newline \n and fnmatch() -curious failures ...

2010-09-27 Thread Peter Lind
On 24 September 2010 12:49, YAD(YetAnotherDavid) ani...@mail.com wrote:
 Peter Lind wrote:

 On 23 September 2010 21:47, YAD(YetAnotherDavid) ani...@mail.com wrote:

 This code is 95% cut and paste from the PHP manual examples -
 the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
 There are actually two questions here - I have combined the code into one

  ...

 Question 1 : how to get the newline functioning ? even print_r()
 output
 is not 'newlined' as it should be. Also note the \n is missing between
 the 
  in the output text of the second test!


 Are you outputting to browser or to command line? Browsers have a
 habit of ignoring whitespaces, reducing them to one whitespace
 character regardless of their type or how many.

 Regards
 Peter


 Thanks Peter, - output is to browser, I develop in Notepad++ and Firefox,
 and confirm in IE8. But this stuff used to work - I have been working with
 PHP for about two years (not pro) and am used to formatting my output for
 legibility - especially echoing or var_dumping variables when still testing
 the code. So the failure is recent and I just can't figure what changed.
 David

Browsers treat newlines as any other whitespace - so print_r and
var_dump will not, on their own, provide you with a linebreak in a
browser. If you've got xdebug installed, var_dump will provide a nicer
output (including line-breaks).
However, by far the easiest way to check if you're actually getting
linebreaks in your output is checking the source.

If you're suddenly experiencing a change in output, then some of your
environment variables have changed - hard to say which one without
knowing more about your system, but you must obviously have
changed/updated something for this to happen.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



[PHP] Heredocs, print_r() and newline \n and fnmatch() - curious failures ...

2010-09-24 Thread YAD(YetAnotherDavid)

This code is 95% cut and paste from the PHP manual examples -
the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
There are actually two questions here - I have combined the code into 
one test file ... the strings in the code contain the questions ..
at the end I have inserted the output I get from the code - identical in 
Firefox and IE8 (so it's not browser related), and on my desktop as well 
as my laptop (so it's not a machine quirk). The setup is Xammplite 
Win32-1.7.1 with PHP 5.2.9 and Apache 2.2.11 on both WinXP-SP3 installs.


I tried Xammp Win32-1.7.3 with the same results. Then I tried installing 
Apache and PHP and MySQL individually, and got the same ...
Aside from the issue here, I also was unable to get imagick and xdebug 
running on the same installation - it was one or the other. imagick's 
readfile() caused Apache to baulk on PHP5.3.3, so I returned to a fresh 
Xammplite setup. Same results.


I have spent many hours with this - I would appreciate some insight ..

Question 1 : how to get the newline functioning ? even print_r() 
output is not 'newlined' as it should be. Also note the \n is missing 
between the   in the output text of the second test!


Question 2 : fnmatch() is an internal function (ie built in to PHP, yet 
get_defined_functions() does not find it. Perhaps there are others also 
missing, I haven't done a check - could it be a compile error in 
Xammplite's PHP binaries?


-
heredoctest.php = the // comments are not in the actual file ...
-
?php
$str = EOD
Example of string
spanning multiple lines
using heredoc syntax.
(this code cut and paste from
the PHP manual examples ...
it just will not work ...!
EOD;
echo $str . \n;//echoes the string, fails on newlines in heredoc
// content and in this newline

/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;

function foo()
{
$this-foo = 'Foo';
$this-bar = array('Bar1', 'Bar2', 'Bar3');
}
}

$foo = new foo();
$name = 'MyName';

echo EOT
My name is $name. I am printing some $foo-foo.
Now, I am printing some {$foo-bar[1]}.
This should print a capital 'A': \x41
EOT;
// again no newlines on direct heredoc echo ...

echo HDOC
a second test for newlines - \n - can't find what is required to
get this to work - have tried everything in the PHP Manual
- still nothing - amazingly even Heredocs does not work.
Tried this on two machines - both running Xammplite 1.7.1. Also
tried installing PHP5.3.3 - and Newdocs doesn't work either. Any ideas?
HDOC;

//note the n gets escaped, but no actual newline occurs in the output
// and the   gets left in the output!

/* And for good measure, here is another bit of frustration - also
 code copied directly from the manual ...
 'fnmatch' is an internal function - yet PHP can't find it ... */

echo some form of gray ...\n ... or grey;  // no newline in output

if (fnmatch(*gr[ae]y, $color)) {// function undefined, dies
  echo some form of gray ...\n ... or grey;
  }
?

-
Here's the output:  - the line breaks are non-existent - here, of course 
the wrapping is imposed by the mail client editor, but in the browser it 
just it all just runs together .. most curious, very frustrating.

-

Example of string spanning multiple lines using heredoc syntax. (this 
code cut and paste from the PHP manual examples ... it just will not 
work ...! My name is MyName. I am printing some Foo. Now, I am 
printing some Bar2. This should print a capital 'A': Aa second test for 
newlines -   - can't find what is required to get this to work - have 
tried everything in the PHP Manual - still nothing - amazingly even 
Heredocs does not work. Tried this on two machines - both running 
Xammplite 1.7.1. Also tried installing PHP5.3.3 - and Newdocs doesn't 
work either. Any ideas?some form of gray ... ... or grey
Fatal error: Call to undefined function fnmatch() in 
C:\xammplite\htdocs\heredoctest.php on line 47


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



Re: [PHP] Heredocs, print_r() and newline \n and fnmatch() - curious failures ...

2010-09-24 Thread Peter Lind
On 23 September 2010 21:47, YAD(YetAnotherDavid) ani...@mail.com wrote:
 This code is 95% cut and paste from the PHP manual examples -
 the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
 There are actually two questions here - I have combined the code into one
 test file ... the strings in the code contain the questions ..
 at the end I have inserted the output I get from the code - identical in
 Firefox and IE8 (so it's not browser related), and on my desktop as well as
 my laptop (so it's not a machine quirk). The setup is Xammplite Win32-1.7.1
 with PHP 5.2.9 and Apache 2.2.11 on both WinXP-SP3 installs.

 I tried Xammp Win32-1.7.3 with the same results. Then I tried installing
 Apache and PHP and MySQL individually, and got the same ...
 Aside from the issue here, I also was unable to get imagick and xdebug
 running on the same installation - it was one or the other. imagick's
 readfile() caused Apache to baulk on PHP5.3.3, so I returned to a fresh
 Xammplite setup. Same results.

 I have spent many hours with this - I would appreciate some insight ..

 Question 1 : how to get the newline functioning ? even print_r() output
 is not 'newlined' as it should be. Also note the \n is missing between the 
  in the output text of the second test!


Are you outputting to browser or to command line? Browsers have a
habit of ignoring whitespaces, reducing them to one whitespace
character regardless of their type or how many.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] Heredocs, print_r() and newline \n and fnmatch() - curious failures ...

2010-09-24 Thread Steve Staples
As far as I know, you wont get any line breaks.

I would suggest putting the results into pre/pre tags to preserve
formatting.

whenever I do a print_r(), i also encapsulate it within a pre/pre
tag so it is readable.

on another note, when I use variables within double quotes  (or even
the heredoc (but i use smarty templates instead)), I always wrap them in
curly braces {} as that is suggested (and I personally think should be
required).

Steve



On Thu, 2010-09-23 at 21:47 +0200, YAD(YetAnotherDavid) wrote:
 This code is 95% cut and paste from the PHP manual examples -
 the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
 There are actually two questions here - I have combined the code into 
 one test file ... the strings in the code contain the questions ..
 at the end I have inserted the output I get from the code - identical in 
 Firefox and IE8 (so it's not browser related), and on my desktop as well 
 as my laptop (so it's not a machine quirk). The setup is Xammplite 
 Win32-1.7.1 with PHP 5.2.9 and Apache 2.2.11 on both WinXP-SP3 installs.
 
 I tried Xammp Win32-1.7.3 with the same results. Then I tried installing 
 Apache and PHP and MySQL individually, and got the same ...
 Aside from the issue here, I also was unable to get imagick and xdebug 
 running on the same installation - it was one or the other. imagick's 
 readfile() caused Apache to baulk on PHP5.3.3, so I returned to a fresh 
 Xammplite setup. Same results.
 
 I have spent many hours with this - I would appreciate some insight ..
 
 Question 1 : how to get the newline functioning ? even print_r() 
 output is not 'newlined' as it should be. Also note the \n is missing 
 between the   in the output text of the second test!
 
 Question 2 : fnmatch() is an internal function (ie built in to PHP, yet 
 get_defined_functions() does not find it. Perhaps there are others also 
 missing, I haven't done a check - could it be a compile error in 
 Xammplite's PHP binaries?
 
 -
 heredoctest.php = the // comments are not in the actual file ...
 -
 ?php
 $str = EOD
 Example of string
 spanning multiple lines
 using heredoc syntax.
 (this code cut and paste from
 the PHP manual examples ...
 it just will not work ...!
 EOD;
 echo $str . \n;//echoes the string, fails on newlines in heredoc
   // content and in this newline
 
 /* More complex example, with variables. */
 class foo
 {
  var $foo;
  var $bar;
 
  function foo()
  {
  $this-foo = 'Foo';
  $this-bar = array('Bar1', 'Bar2', 'Bar3');
  }
 }
 
 $foo = new foo();
 $name = 'MyName';
 
 echo EOT
 My name is $name. I am printing some $foo-foo.
 Now, I am printing some {$foo-bar[1]}.
 This should print a capital 'A': \x41
 EOT;
   // again no newlines on direct heredoc echo ...
   
 echo HDOC
 a second test for newlines - \n - can't find what is required to
 get this to work - have tried everything in the PHP Manual
 - still nothing - amazingly even Heredocs does not work.
 Tried this on two machines - both running Xammplite 1.7.1. Also
 tried installing PHP5.3.3 - and Newdocs doesn't work either. Any ideas?
 HDOC;
 
 //note the n gets escaped, but no actual newline occurs in the output
 // and the   gets left in the output!
 
 /* And for good measure, here is another bit of frustration - also
   code copied directly from the manual ...
   'fnmatch' is an internal function - yet PHP can't find it ... */
 
 echo some form of gray ...\n ... or grey;  // no newline in output
 
 if (fnmatch(*gr[ae]y, $color)) {// function undefined, dies
echo some form of gray ...\n ... or grey;
}
 ?
 
 -
 Here's the output:  - the line breaks are non-existent - here, of course 
 the wrapping is imposed by the mail client editor, but in the browser it 
 just it all just runs together .. most curious, very frustrating.
 -
 
 Example of string spanning multiple lines using heredoc syntax. (this 
 code cut and paste from the PHP manual examples ... it just will not 
 work ...! My name is MyName. I am printing some Foo. Now, I am 
 printing some Bar2. This should print a capital 'A': Aa second test for 
 newlines -   - can't find what is required to get this to work - have 
 tried everything in the PHP Manual - still nothing - amazingly even 
 Heredocs does not work. Tried this on two machines - both running 
 Xammplite 1.7.1. Also tried installing PHP5.3.3 - and Newdocs doesn't 
 work either. Any ideas?some form of gray ... ... or grey
 Fatal error: Call to undefined function fnmatch() in 
 C:\xammplite\htdocs\heredoctest.php on line 47
 



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