Re: [PHP] print a to z

2009-01-16 Thread Jochem Maas
paragasu schreef:
 i have this cute little problem.

sounds more like a homework assignment. by now you know range(),
by all means have array_map() too:

array_map(print_r, range(a,z));

 i want to print a to z for site navigation
 my first attempt work fine
 
 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);
 
 but someone point me a more interesting solutions
 
 for($i = 'a'; $i  'z'; ++$i)
   echo $i
 
 the only problem with the 2nd solutions is it only print up to Y without z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

STFA - Rasmus Lerdorf has explained exactly why this works the
way it does more than once IIRC.

 thanks
 


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



Re: [PHP] print a to z

2009-01-15 Thread Chris

paragasu wrote:

i have this cute little problem. i want to print a to z for site navigation
my first attempt work fine

for($i = '65'; $i  '91'; ++$i)
  echo chr($i);

but someone point me a more interesting solutions


$letters = range('a', 'z');
foreach ($letters as $letter) {
  echo $letter;
}

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] print a to z

2009-01-15 Thread paragasu
 $letters = range('a', 'z');
 foreach ($letters as $letter) {
 echo $letter;
 }

wow.. that is a very nice solutions you give me chris.
thanks

On 1/15/09, Chris dmag...@gmail.com wrote:
 paragasu wrote:
 i have this cute little problem. i want to print a to z for site
 navigation
 my first attempt work fine

 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);

 but someone point me a more interesting solutions

 $letters = range('a', 'z');
 foreach ($letters as $letter) {
echo $letter;
 }

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



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



Re: [PHP] print a to z

2009-01-15 Thread Paul M Foster
On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote:

 i have this cute little problem. i want to print a to z for site navigation
 my first attempt work fine
 
 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);
 
 but someone point me a more interesting solutions
 
 for($i = 'a'; $i  'z'; ++$i)
   echo $i
 
 the only problem with the 2nd solutions is it only print up to Y without z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

for ($i = 'a'; $i = 'z'; $i++)
echo $i;

Paul

-- 
Paul M. Foster

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



RE: [PHP] print a to z

2009-01-15 Thread Leon du Plessis
I used that notation before, and it did not work 100%. 
Adapt as follows:

for ($i = 'a'; $i = 'z'; $i++)
if ($i == aa) break; else echo $i;

-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: 16 January 2009 07:55 AM
To: php-general@lists.php.net
Subject: Re: [PHP] print a to z

On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote:

 i have this cute little problem. i want to print a to z for site
navigation
 my first attempt work fine
 
 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);
 
 but someone point me a more interesting solutions
 
 for($i = 'a'; $i  'z'; ++$i)
   echo $i
 
 the only problem with the 2nd solutions is it only print up to Y without
z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

for ($i = 'a'; $i = 'z'; $i++)
echo $i;

Paul

-- 
Paul M. Foster

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


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



Re: [PHP] print a to z

2009-01-15 Thread Lars Torben Wilson
2009/1/15 Leon du Plessis l...@dsgnit.com:
 I used that notation before, and it did not work 100%.
 Adapt as follows:

 for ($i = 'a'; $i = 'z'; $i++)
if ($i == aa) break; else echo $i;

It's weird, but true--the simple '=' breaks the loop.

However, in the above example, you don't need the 'else'; the 'break'
ensures that the 'echo $i'; will not execute.

You can step around the the problem more elegantly:

for ($i = 'a'; $i !== 'aa'; $i++) {
   echo $i;
}


Regards,

Torben

 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: 16 January 2009 07:55 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] print a to z

 On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote:

 i have this cute little problem. i want to print a to z for site
 navigation
 my first attempt work fine

 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);

 but someone point me a more interesting solutions

 for($i = 'a'; $i  'z'; ++$i)
   echo $i

 the only problem with the 2nd solutions is it only print up to Y without
 z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

 for ($i = 'a'; $i = 'z'; $i++)
echo $i;

 Paul

 --
 Paul M. Foster

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



Re: [PHP] print a to z

2009-01-15 Thread Kevin Waterson
This one time, at band camp, Leon du Plessis l...@dsgnit.com wrote:

 I used that notation before, and it did not work 100%. 
 Adapt as follows:
 
 for ($i = 'a'; $i = 'z'; $i++)
 if ($i == aa) break; else echo $i;
 


foreach(range('a', 'z') as $letter ) { echo $letter; }

Kevin


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



Re: [PHP] print() or echo

2007-02-13 Thread Robert Cummings
On Tue, 2007-02-13 at 19:19 +0330, Danial Rahmanzadeh wrote:
 is it true that echo is a bit faster than print()? in general, when we don't
 need a return value, which one is better to choose?

Yes, echo is faster than print. I would suggest echo over print since it
is shorter and faster :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] print() or echo

2007-02-13 Thread tg-php
As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ), 
check out this url:
http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

Short story, there is a difference, but the speed difference is negligable.

If anyone cares, I prefer echo too.  Not sure why.  Shorter to type, old habits 
(coming more from a scripting background than a real programming background 
even though I've done some of that too), who knows?  Part of it may be the 
desire to have my code do what it needs to do and nothing more.  Print returns 
a value, which I don't use, so why would I want it to do that?   That's a 
little anal retentive, but every little bit helps I suppose, even if it's a 
negligable difference.

-TG

= = = Original message = = =

On Tue, 2007-02-13 at 19:19 +0330, Danial Rahmanzadeh wrote:
 is it true that echo is a bit faster than print()? in general, when we don't
 need a return value, which one is better to choose?

Yes, echo is faster than print. I would suggest echo over print since it
is shorter and faster :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] print() or echo

2007-02-13 Thread tg-php
negligible.. blarg spelling.  :)

= = = Original message = = =

As referenced in the manual ( http://us2.php.net/manual/en/function.echo.php ), 
check out this url:
http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

Short story, there is a difference, but the speed difference is negligable.

If anyone cares, I prefer echo too.  Not sure why.  Shorter to type, old habits 
(coming more from a scripting background than a real programming background 
even though I've done some of that too), who knows?  Part of it may be the 
desire to have my code do what it needs to do and nothing more.  Print returns 
a value, which I don't use, so why would I want it to do that?   That's a 
little anal retentive, but every little bit helps I suppose, even if it's a 
negligable difference.

-TG

= = = Original message = = =

On Tue, 2007-02-13 at 19:19 +0330, Danial Rahmanzadeh wrote:
 is it true that echo is a bit faster than print()? in general, when we don't
 need a return value, which one is better to choose?

Yes, echo is faster than print. I would suggest echo over print since it
is shorter and faster :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] print() or echo

2007-02-13 Thread Satyam
echo is slightly faster than print and it takes multiple arguments so 
instead of:


echo 'p' . $test . '/p';

you can do

echo 'p' , $test , '/p';

which should be faster, and I say 'should' just because as print should be 
slower because it has to go into the trouble of setting up a return value, 
so avoiding doing a concatenation first and then output the whole thing by 
just streaming each of the pieces to the output straight away should be 
faster, though string operations are so optimized as to be neglig 
well, you can't tell the difference.


Satyam

- Original Message - 
From: Danial Rahmanzadeh [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Tuesday, February 13, 2007 4:49 PM
Subject: [PHP] print() or echo


is it true that echo is a bit faster than print()? in general, when we 
don't

need a return value, which one is better to choose?
Cheers,
Danial Rahmanzadeh







No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.37/682 - Release Date: 12/02/2007 
13:23


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



Re: [PHP] Print or Echo takes lots of time

2006-09-28 Thread Ivo F.A.C. Fokkema
On Tue, 26 Sep 2006 21:45:58 +1000, David Tulloh wrote:

 Google Kreme wrote:
 On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
 ...
 
 If this is generating hundred of K of HTML, use ' instead of 
 
 (yes, it's faster).
 
 
 I've seen this stated several times and at first glance it seems to make
 sense.  The double quoted version has all the \n and related characters
 that need to be handled.
 
 Except that php is a C program and uses the printf family of functions.
  This means that all the single quoted strings actually have to be
 converted to escaped versions of double quoted strings, so internally
 '\n' becomes \\n.
 
 You can see this in some benchmarks, I ran the following script and a
 single quoted version from the command line.  I ran each 10 times,
 interleaved to try to balance changes in the system load.
 
 ?php
 $str=;
 for($i=0; $i1000; $i++)
 $str.=foo;
 ?
 
 I found that the double quoted version averaged 5.5516 seconds against
 the single quoted script of 5.5627.  Which really goes to show that
 while the double quoted version is faster the difference is almost
 completely irrelevent.

While we're at it (running benchmarks three times, varying amount of loops):

Benchmarking with 100K loops
Case 1 : 'Adding a 10-character single quoted string to a var'
Time   : 0.23s - 0.24s 
Case 2 : 'Adding a 10-character double quoted string to a var'
Time   : 0.23s - 0.24s 
Performance : Anywhere between Decreased 1.1% and Increased 26.7%

This seems really funny to me, cause I was under the impression a single
quoted string was faster... I remember benchmarking that before.



Benchmarking with 10K loops
Case 1 : 'Adding a 100-character single quoted string to a var'
Time   : 0.03s - 0.08s
Case 2 : 'Adding a 100-character double quoted string to a var'
Time   : 0.03s 
Performance : Anywhere between Increased 0.7% and Increased 66.9%

Still funny... and numbers get higher, too.



Benchmarking with 1M loops
Case 1 : 'Setting a var with a 100-character single quoted string'
Time   : 2.29s - 2.63s 
Case 2 : 'Setting a var with a 100-character double quoted string'
Time   : 2.53 - 2.78s 
Performance : Anywhere between Decreased 3.1% and Decreased 16.3%

Now this is probably what I saw previously and what made me decide using
single quotes where possible.



Benchmarking with 1M loops
Case 1 : 'Setting a var with a 100-character single quoted string incl. a 
variable (concat)'
Time   : 3.59s - 4.07s
Case 2 : 'Setting a var with a 100-character double quoted string incl. a 
variable'
Time   : 4.14s - 4.40s
Performance : Anywhere between Decreased 8.2% - Decreased 19.2%

Well, try not to use variables in a string, but concatenate it together.



Benchmarking with 1M loops
Case 1 : 'Setting a var with a 100-character double quoted string incl. a 
variable (concat)'
Time   : 3.58s - 3.79s
Case 2 : 'Setting a var with a 100-character double quoted string incl. a 
variable'
Time   : 4.12s - 5.24s
Performance : Anywhere between Decreased 14.9% - Decreased 38.4%

Same with using double quoted strings only...



Hey! It's coffee break already!

Ivo

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



Re: [PHP] Print or Echo takes lots of time

2006-09-27 Thread Richard Lynch
On Wed, September 27, 2006 3:37 am, Sancar Saran wrote:
 Thanks for supporting, because of approaching the problem I don't want
 to
 change generate once echo one style.

 And I found solution like this,
 I split  variable into an array and generate loop for printing, mostly
 fix the
 problem.

 And more interesting, some times problem repeates himself. I believe
 this was
 connected to php memory performance.

 Anyhow is there any information about optimal echo or print size ?

You could try to generate some stats to add to the pool of knowledge.

I suspect it's so tied to hardware, load, OS, bandwidth-pipesize that
all that has to be reported to be useful.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread David Tulloh
Google Kreme wrote:
 On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
 ...
 
 If this is generating hundred of K of HTML, use ' instead of 
 
 (yes, it's faster).
 

I've seen this stated several times and at first glance it seems to make
sense.  The double quoted version has all the \n and related characters
that need to be handled.

Except that php is a C program and uses the printf family of functions.
 This means that all the single quoted strings actually have to be
converted to escaped versions of double quoted strings, so internally
'\n' becomes \\n.

You can see this in some benchmarks, I ran the following script and a
single quoted version from the command line.  I ran each 10 times,
interleaved to try to balance changes in the system load.

?php
$str=;
for($i=0; $i1000; $i++)
$str.=foo;
?

I found that the double quoted version averaged 5.5516 seconds against
the single quoted script of 5.5627.  Which really goes to show that
while the double quoted version is faster the difference is almost
completely irrelevent.


David

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Børge Holen
On Tuesday 26 September 2006 02:07, Robert Cummings wrote:
 On Mon, 2006-09-25 at 17:39 -0600, Google Kreme wrote:
  I'm sitting here with 4 Gigs of RAM trying to figure out how to use
  it all... :-)  (Me, in 2005)

 Not really related to the post... but I find a good way to eat up 4 gigs
 of RAM is to run several VMWare nodes :) Depending on what these nodes
 do, it can also be a great way to eat up those dual core processors :)

Forget 'bout em vmware stuff. Imagine putting those ramdisks to good use.



 Cheers,
 Rob.
 --
 ..

 | InterJinn Application Framework - http://www.interjinn.com |
 |
 ::
 :
 | An application and templating framework for PHP. Boasting  |
 | a powerful, scalable system for accessing system services  |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for   |
 | creating re-usable components quickly and easily.  |

 `'

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Richard Lynch
On Mon, September 25, 2006 7:11 am, Sancar Saran wrote:
 When I was check the performance of my system I found interesting
 resuts.

 My code stores html output into a variable. When page creation
 complete I
 printed out the variable.

 Problem was generation html code takes 0.5 second and just
 echo $strPage takes 2.0 or more second.

 my code structure was.

 $strPage = html yada dayda;
 ...
 $strPage.=  another html tags;
 ...
 $strPage.= getSqlDataAndCreateSomeHtmlCOde();
 ...
 end of page creation.
 Current Total execution time 0.5 seconds.
 print $strPage;
 Current Total execution time 2.5 seconds.

 $strPage carries entire html structure (for example equal of 100K html
 code);

 excluding the cookie and other kind of header transfers and error
 messages,
 there was no print or echo command was submitted.

 Is there any idea about this latency and any idea to find problem...

You could try echo-ing it out in chunks instead of waiting until the
very end.

echo/print has to send the data out through the very narrow pipe to
Apache - the browser

If you send every little snippet one tiny piece at a time, you waste
resources.

If you wait until the end and send out some huge monster string, you
waste resources.

Find the balance if you can.

Depends on your hardware/bandwidth exactly where optimum is.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Richard Lynch
On Tue, September 26, 2006 12:16 pm, Børge Holen wrote:
 On Tuesday 26 September 2006 02:07, Robert Cummings wrote:
 On Mon, 2006-09-25 at 17:39 -0600, Google Kreme wrote:
  I'm sitting here with 4 Gigs of RAM trying to figure out how to
 use
  it all... :-)  (Me, in 2005)

 Not really related to the post... but I find a good way to eat up 4
 gigs
 of RAM is to run several VMWare nodes :) Depending on what these
 nodes
 do, it can also be a great way to eat up those dual core processors
 :)

 Forget 'bout em vmware stuff. Imagine putting those ramdisks to good
 use.

I wonder what would happen if you put your swap on a RAM disk?

Wouldn't that be really fast?!

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Curt Zirzow

On 9/26/06, Richard Lynch [EMAIL PROTECTED] wrote:

On Tue, September 26, 2006 12:16 pm, Børge Holen wrote:
 On Tuesday 26 September 2006 02:07, Robert Cummings wrote:
 On Mon, 2006-09-25 at 17:39 -0600, Google Kreme wrote:
  I'm sitting here with 4 Gigs of RAM trying to figure out how to
 use
  it all... :-)  (Me, in 2005)

 Not really related to the post... but I find a good way to eat up 4
 gigs
 of RAM is to run several VMWare nodes :) Depending on what these
 nodes
 do, it can also be a great way to eat up those dual core processors
 :)

 Forget 'bout em vmware stuff. Imagine putting those ramdisks to good
 use.

I wonder what would happen if you put your swap on a RAM disk?


I actually have done this, it works like a charm :)

you just have to ensure swap doesn't run out... of course i'd only
recomend this on a dedicated machine for like firewalling or a
gateway.

Curt

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Richard Lynch
On Tue, September 26, 2006 6:35 pm, Curt Zirzow wrote:
 I wonder what would happen if you put your swap on a RAM disk?

 I actually have done this, it works like a charm :)

 you just have to ensure swap doesn't run out... of course i'd only
 recomend this on a dedicated machine for like firewalling or a
 gateway.

Like...

Wouldn't it just make more sense to not have swap at all?...

I mean, you can only be increasing overhead and whatnot...

I suppose if you just plain CANNOT build the system with no swap,
because the tools won't let you do that...

H.  Never tried to build a swap-less box, for obvious reasons...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Robert Cummings
On Tue, 2006-09-26 at 18:46 -0500, Richard Lynch wrote:
 On Tue, September 26, 2006 6:35 pm, Curt Zirzow wrote:
  I wonder what would happen if you put your swap on a RAM disk?
 
  I actually have done this, it works like a charm :)
 
  you just have to ensure swap doesn't run out... of course i'd only
  recomend this on a dedicated machine for like firewalling or a
  gateway.
 
 Like...
 
 Wouldn't it just make more sense to not have swap at all?...
 
 I mean, you can only be increasing overhead and whatnot...
 
 I suppose if you just plain CANNOT build the system with no swap,
 because the tools won't let you do that...
 
 H.  Never tried to build a swap-less box, for obvious reasons...

*lol* I was gonna say, why the hell would anyone make swap into a
ramdisk when the memory used for the ramdisk would be better used as
primary RAM. I presumed you were joking Richard which you clarify above,
but Curtis now has me wondering :B The only time I'd use a ramdisk for
swap is if I had the extra cash to shell out for one of the pretend hard
drives that really map to RAM... like this sucker:

http://www.shoprbc.com/ca/shop/product_details.php?pid=13968

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Fwd: Re: [PHP] Print or Echo takes lots of time

2006-09-26 Thread Børge Holen


--  Forwarded Message  --

Subject: Re: [PHP] Print or Echo takes lots of time
Date: Wednesday 27 September 2006 06:37
From: Børge Holen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]

On Wednesday 27 September 2006 01:46, Richard Lynch wrote:
 On Tue, September 26, 2006 6:35 pm, Curt Zirzow wrote:
  I wonder what would happen if you put your swap on a RAM disk?
 
  I actually have done this, it works like a charm :)
 
  you just have to ensure swap doesn't run out... of course i'd only
  recomend this on a dedicated machine for like firewalling or a
  gateway.

 Like...

 Wouldn't it just make more sense to not have swap at all?...

 I mean, you can only be increasing overhead and whatnot...

 I suppose if you just plain CANNOT build the system with no swap,
 because the tools won't let you do that...

 H.  Never tried to build a swap-less box, for obvious reasons...

I've done that since '01.
Never any occurences (witch WILL happen whenever you run out). Of course
 never on a production machine, but my desktop and laptop sure got none.

 --
 Like Music?
 http://l-i-e.com/artists.htm

--
---
Børge
Kennel Arivene
http://www.arivene.net
---

---

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] Print or Echo takes lots of time

2006-09-25 Thread Google Kreme

On 25 Sep 2006, at 06:11 , Sancar Saran wrote:

$strPage = html yada dayda;
...
$strPage.=  another html tags;
...
$strPage.= getSqlDataAndCreateSomeHtmlCOde();


If this is generating hundred of K of HTML, use ' instead of 

(yes, it's faster).

--  
I'm sitting here with 4 Megs of RAM trying to figure out how to use  
it all... :-)  (Me, in 1990)
I'm sitting here with 4 Gigs of RAM trying to figure out how to use  
it all... :-)  (Me, in 2005)


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



Re: [PHP] Print or Echo takes lots of time

2006-09-25 Thread Robert Cummings
On Mon, 2006-09-25 at 17:39 -0600, Google Kreme wrote:

 I'm sitting here with 4 Gigs of RAM trying to figure out how to use  
 it all... :-)  (Me, in 2005)

Not really related to the post... but I find a good way to eat up 4 gigs
of RAM is to run several VMWare nodes :) Depending on what these nodes
do, it can also be a great way to eat up those dual core processors :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] print page from php

2006-03-20 Thread Reinhart Viane
Thx Miles and Jay

-Oorspronkelijk bericht-
Van: Miles Thompson [mailto:[EMAIL PROTECTED] 
Verzonden: vrijdag 17 maart 2006 22:35
Aan: php-general@lists.php.net
Onderwerp: Re: [PHP] print page from php

At 09:57 AM 3/17/2006, Reinhart Viane wrote:

All,

I have a web page with the results from several database queries.
Now this page has an undefined horizontal and vertical size.

Does anyone know if there is a php script available that will automatically
split the webpage into parts that can fit on an A4 page?

Or do I have to set boundaries on the size of the tables the queried data
will be shown in.

Hope this makes any sense,

Thanks in advance,

Reinhart Viane

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


CSS is probably the best solution
 http://www.w3.org/TR/REC-CSS2/page.html#q16
found whle googling
 
http://www.google.ca/search?hl=enq=printing+CSS+mediabtnG=Google+Search

This is a good article:
http://css-discuss.incutio.com/?page=PrintStylesheets
and as always, A List Apart has CSS Design: going to Print at 
http://www.alistapart.com/stories/goingtoprint/

I have seen examples of two-column pages, but do not know if the pages 
broke correctly when the matter was longer than one page.

Alternately, display in tables and make certain you have a TH so your 
header can repeat.

Hope this steers you in the right direction - Miles. 


-- 
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 268.2.1/279 - Release Date: 3/10/2006

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

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



RE: [PHP] print page from php

2006-03-17 Thread Jay Blanchard
[snip]
I have a web page with the results from several database queries.
Now this page has an undefined horizontal and vertical size.

Does anyone know if there is a php script available that will
automatically
split the webpage into parts that can fit on an A4 page?

Or do I have to set boundaries on the size of the tables the queried
data
will be shown in.
[/snip]

Create a CSS print stylesheet.
http://www.alistapart.com/articles/goingtoprint/

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



Re: [PHP] print page from php

2006-03-17 Thread Miles Thompson

At 09:57 AM 3/17/2006, Reinhart Viane wrote:


All,

I have a web page with the results from several database queries.
Now this page has an undefined horizontal and vertical size.

Does anyone know if there is a php script available that will automatically
split the webpage into parts that can fit on an A4 page?

Or do I have to set boundaries on the size of the tables the queried data
will be shown in.

Hope this makes any sense,

Thanks in advance,

Reinhart Viane

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



CSS is probably the best solution
http://www.w3.org/TR/REC-CSS2/page.html#q16
found whle googling

http://www.google.ca/search?hl=enq=printing+CSS+mediabtnG=Google+Search

This is a good article: http://css-discuss.incutio.com/?page=PrintStylesheets
and as always, A List Apart has CSS Design: going to Print at 
http://www.alistapart.com/stories/goingtoprint/


I have seen examples of two-column pages, but do not know if the pages 
broke correctly when the matter was longer than one page.


Alternately, display in tables and make certain you have a TH so your 
header can repeat.


Hope this steers you in the right direction - Miles. 



--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 268.2.1/279 - Release Date: 3/10/2006

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



Re: [PHP] Print extended/parent classes

2006-02-01 Thread David Grant
Mathijs,

Mathijs wrote:
 I have the following situation :
 
 ?php
 
 class A {
 public $var1;
 }
 
 class B extends A {
 public $var2;
 }
 
 ?
 
 Now I want to print this object
 ?php
 
 $obj = new B;
 print_r($obj);
 
 ?
 
 Does anybody know how I can print class A also ?

The above prints out:

B Object
(
[var2] =
[var1] =
)

Is this not what you expected?  You can't print out *just* the
properties of A.  If this isn't what you want, you shouldn't be extending A.

David
-- 
David Grant
http://www.grant.org.uk/

http://pear.php.net/package/File_Ogg0.2.1
http://pear.php.net/package/File_XSPF   0.1.0

WANTED: Junior PHP Developer in Bristol, UK

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



Re: [PHP] Print extended/parent classes

2006-02-01 Thread Jochem Maas

David Grant wrote:

Mathijs,

Mathijs wrote:


I have the following situation :

?php

class A {
public $var1;
}

class B extends A {
public $var2;
}

?

Now I want to print this object


***object***


?php

$obj = new B;
print_r($obj);

?

Does anybody know how I can print class A also ?


***class***

(class and object are not interchangable concepts - yet
they are closely related :-)

you printed $obj which is an instance of B, which happens to
be a subclass of A. if you are interested to find out which classes
an objects is defined by try something like:

class A {}
class B extends A {}
class C extends B {}
$c = C; $classes = array($c);
while($c = get_parent_class($c))
$classes[] = $c;
print_r($classes);




The above prints out:

B Object
(
[var2] =
[var1] =
)

Is this not what you expected?  You can't print out *just* the
properties of A.  If this isn't what you want, you shouldn't be extending A.

David


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



Re: [PHP] Print extended/parent classes

2006-02-01 Thread David Grant
Jochem,

Good point.  I thought he meant object given his example. :P

David

Jochem Maas wrote:
 David Grant wrote:
 Mathijs,

 Mathijs wrote:

 I have the following situation :

 ?php

 class A {
 public $var1;
 }

 class B extends A {
 public $var2;
 }

 ?

 Now I want to print this object
 
 ***object***
 
 ?php

 $obj = new B;
 print_r($obj);

 ?

 Does anybody know how I can print class A also ?
 
 ***class***
 
 (class and object are not interchangable concepts - yet
 they are closely related :-)
 
 you printed $obj which is an instance of B, which happens to
 be a subclass of A. if you are interested to find out which classes
 an objects is defined by try something like:
 
 class A {}
 class B extends A {}
 class C extends B {}
 $c = C; $classes = array($c);
 while($c = get_parent_class($c))
 $classes[] = $c;
 print_r($classes);
 


 The above prints out:

 B Object
 (
 [var2] =
 [var1] =
 )

 Is this not what you expected?  You can't print out *just* the
 properties of A.  If this isn't what you want, you shouldn't be
 extending A.

 David
 


-- 
David Grant
http://www.grant.org.uk/

http://pear.php.net/package/File_Ogg0.2.1
http://pear.php.net/package/File_XSPF   0.1.0

WANTED: Junior PHP Developer in Bristol, UK

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



RE: [PHP] print value from db

2005-07-29 Thread Jay Blanchard
[snip]
Hi, I have a table with:

month, day, year, value

I need to print every value corresponding to a day, for example:

value[day1], if exist..
value[day2], if exist..
vale...

etc

It is possible?
[/snip]


Welcome to Is It Possible Day at the PHP Ranch. :)

Yes, it is possible to print every avlue corresponding to a day.

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



RE: [PHP] Print window function???

2004-10-15 Thread Steve Murphy
Web standards my friend.

Use CSS, learn from the master: http://www.alistapart.com/articles/goingtoprint/

-Original Message-
From: Tony Kim [mailto:[EMAIL PROTECTED]
Sent: Friday, October 15, 2004 3:10 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Print window function???


Is there a function for print window in php? I tried javascript
window.print() but this doesn't work in ie 5.2 on mac. Thanks. 

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


Re: [PHP] print at a specific time

2004-09-02 Thread devil_online
thanks...
On Wed, 1 Sep 2004 22:18:30 -0500, Brent Clements  
[EMAIL PROTECTED] wrote:

Sorry forgot to enclose the variable values. doh!
I needs more coffee!
-Brent
- Original Message -
From: John Holmes [EMAIL PROTECTED]
To: Brent Clements [EMAIL PROTECTED]
Cc: devil_online [EMAIL PROTECTED];  
[EMAIL PROTECTED]
Sent: Wednesday, September 01, 2004 10:12 PM
Subject: Re: [PHP] print at a specific time


Brent Clements wrote:
 $minute = 01;
Be careful with the leading zeros... that's interpreted as an Octal
number by PHP, but Octal 1 == Decimal 1 in this case. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] print at a specific time

2004-09-02 Thread devil_online
thanks
On Wed, 1 Sep 2004 22:18:30 -0500, Brent Clements  
[EMAIL PROTECTED] wrote:



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] print at a specific time

2004-09-01 Thread John Holmes
devil_online wrote:
Hi, I want to print or echo something in a specific time like 9.pm.
how can i do it?
if(date('H')==21)
{ echo 'tis 9pm and all is well?; }
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] print at a specific time

2004-09-01 Thread devil_online
and to print at minutes too, kije 9h01?

thanks
John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 devil_online wrote:

  Hi, I want to print or echo something in a specific time like 9.pm.
  how can i do it?

 if(date('H')==21)
 { echo 'tis 9pm and all is well?; }

 -- 

 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Re: [PHP] print at a specific time

2004-09-01 Thread Brent Clements
?php
$hour = 21;
$minute = 01;
if(date('H')==$hour AND date('i')==$minute) 
{ echo tis $hour:$minute and all is well?; }
?

- Original Message - 
From: devil_online [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 01, 2004 9:05 PM
Subject: Re: [PHP] print at a specific time


 and to print at minutes too, kije 9h01?
 
 thanks
 John Holmes [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  devil_online wrote:
 
   Hi, I want to print or echo something in a specific time like 9.pm.
   how can i do it?
 
  if(date('H')==21)
  { echo 'tis 9pm and all is well?; }
 
  -- 
 
  ---John Holmes...
 
  Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
 
  php|architect: The Magazine for PHP Professionals - www.phparch.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP] print at a specific time

2004-09-01 Thread John Holmes
Brent Clements wrote:
$minute = 01;
Be careful with the leading zeros... that's interpreted as an Octal 
number by PHP, but Octal 1 == Decimal 1 in this case. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] print at a specific time

2004-09-01 Thread Brent Clements
Sorry forgot to enclose the variable values. doh!

I needs more coffee!

-Brent
- Original Message - 
From: John Holmes [EMAIL PROTECTED]
To: Brent Clements [EMAIL PROTECTED]
Cc: devil_online [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, September 01, 2004 10:12 PM
Subject: Re: [PHP] print at a specific time


 Brent Clements wrote:

  $minute = 01;

 Be careful with the leading zeros... that's interpreted as an Octal
 number by PHP, but Octal 1 == Decimal 1 in this case. :)

 -- 

 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals  www.phparch.com

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



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



Re: [PHP] print a element of a column

2004-08-29 Thread John Nichel
devil_online wrote:
Hi, I want to print each element of a column of a mysql database.
For exemple to print the first element could we do like this:
  Code:
  $result = mysql_query( SELECT username FROM users );
  $column = mysql_fetch_array($result);
  print $column[1];
  print $column[3];

Thanks

You need to loop thru the result set if it's going to return more than 
one row

while ( $column = mysql_fetch_array ( $result ) {
print $column[0];
}
In your query above, there won't be a $column[1] [2], etc., since you're 
only selecting 'username'.  'username' will be the first and only element.

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Print page without images

2004-07-20 Thread Gerben
css:

img{display:none;}

John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 francesco[AT]automationsoft[DOT]biz wrote:

  I know that it is a simple and maybe elementary
  question, but there is in PHP a function, like print
  or echo, that print only the text of an HTML page on printer?

 No. Use CSS.

 --
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Re: [PHP] Print page without images

2004-07-20 Thread Curt Zirzow
* Thus wrote Gerben:
 css:
 
 img{display:none;}

Dont forget to mention the media:

@media print {
  img { display: none; }
}

Of course this is going on the assumption you dont have things like

  tdimg src=/trans.gif width=233 height=30/td


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Print page without images

2004-07-19 Thread John W. Holmes
francesco[AT]automationsoft[DOT]biz wrote:
I know that it is a simple and maybe elementary 
question, but there is in PHP a function, like print 
or echo, that print only the text of an HTML page on printer?
No. Use CSS.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Print a variable's name

2004-05-05 Thread Ryan A
Just escape it...

eg:

$ryan = something;

echo \$ryan =.$ryan;

that would print:


$ryan = something

HTH.

Cheers,
-Ryan



On 5/5/2004 5:02:25 PM, [EMAIL PROTECTED] wrote:
 I'd like to print a variable's name in a procedure along with it's
value

 Is there a way to do this?


 for example:
 --
-
 function showvar($somevar) {

 echo Now showing: . ... code to show var name . .\n;
 echo Value: .$somevar;

 }

 $s1 = Hello World;
 showvar($s1);
 --
-

 would produce:
 --
-
 Now showing: $s1
 Value: Hello World
 --
-


 many thanks in advance...
 Ahbaid

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

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



Re: [PHP] Print a variable's name

2004-05-05 Thread Ahbaid Gaffoor
Thanks Ryan,
but what I want is to be able to pass any variable to a procedure and 
have the variable name and value printed by the procedure.

Can this be done?
I'm trying to extend my library of debugging functions/procedures by 
having a procedure which can be used to inspect a variable whenever I 
call it.

Thanks
Ahbaid
Ryan A wrote:
Just escape it...
eg:
$ryan = something;
echo \$ryan =.$ryan;
that would print:
$ryan = something
HTH.
Cheers,
-Ryan

On 5/5/2004 5:02:25 PM, [EMAIL PROTECTED] wrote:
 

I'd like to print a variable's name in a procedure along with it's
   

value
 

Is there a way to do this?
for example:
--
   

-
 

function showvar($somevar) {
echo Now showing: . ... code to show var name . .\n;
echo Value: .$somevar;
}
$s1 = Hello World;
showvar($s1);
--
   

-
 

would produce:
--
   

-
 

Now showing: $s1
Value: Hello World
--
   

-
 

many thanks in advance...
Ahbaid
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   

 



RE: [PHP] Print a variable's name

2004-05-05 Thread Michael Sims
Ahbaid Gaffoor wrote:
 Thanks Ryan,
 
 but what I want is to be able to pass any variable to a procedure and
 have the variable name and value printed by the procedure.
 
 Can this be done?
 
 I'm trying to extend my library of debugging functions/procedures by
 having a procedure which can be used to inspect a variable whenever
 I call it.

This is a bit kludgy, but should work:

function showvar($varname) {

  if (!isset($GLOBALS[$varname])) { return; }

  echo Now showing: $varname\n;
  echo Value: .$GLOBALS[$varname].\n;

}

$s1 = Hello World;
showvar('s1');

HTH

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



RE: [PHP] Print a variable's name

2004-05-05 Thread Dave Avent
$test = Hello World!;

function showvar($var) {

foreach($GLOBALS as $key = $value) {
if($value == $var) {
$varname = $key;
}   
}
echo Variable Name: .$varname.br\n;
echo Variable Value: .$var.br\n;
}


showvar($test);


This is the only thing that works for me.I know it is messy

-Original Message-
From: Michael Sims [mailto:[EMAIL PROTECTED]
Sent: 05 May 2004 4:23 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Print a variable's name


Ahbaid Gaffoor wrote:
 Thanks Ryan,
 
 but what I want is to be able to pass any variable to a procedure and
 have the variable name and value printed by the procedure.
 
 Can this be done?
 
 I'm trying to extend my library of debugging functions/procedures by
 having a procedure which can be used to inspect a variable whenever
 I call it.

This is a bit kludgy, but should work:

function showvar($varname) {

  if (!isset($GLOBALS[$varname])) { return; }

  echo Now showing: $varname\n;
  echo Value: .$GLOBALS[$varname].\n;

}

$s1 = Hello World;
showvar('s1');

HTH

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

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



RE: [PHP] Print a variable's name

2004-05-05 Thread Michael Sims
Dave Avent wrote:
   function showvar($var) {

   foreach($GLOBALS as $key = $value) {
   if($value == $var) {
   $varname = $key;
   }
   }

The problem with the above is that it assumes that there will never be more than one
global variable that contains the same value, and will give incorrect output in this
case:

$s1 = Hello World;
...
$s2 = Hello World;
...
showvar($s1);

Also it's probably a better idea to have the showvar function use print_r() or
var_export() in case it is passed something other than a scalar.

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



Re: [PHP] Print a variable's name - FIXED

2004-05-05 Thread Ahbaid Gaffoor
I didn't say SOLVED becuase this gets me sor of what I want :
I added to the function an optional parameter so that if I reall wanted 
the var name to show I can pass it in...

I know it's messy, but for debugging it's fine:
function showvar($var,$varname=Var: ) {
   echo Now Showing .$varname.: br\n;
   echo $var;
}
This way I supply the var name if I want to.. such as:
$s1 = Hello World;
showvar($s1,s1);
or
showvar($s1);
thanks all
Ahbaid.
Dave Avent wrote:
$test = Hello World!;

function showvar($var) {
foreach($GLOBALS as $key = $value) {
if($value == $var) {
$varname = $key;
}   
}
echo Variable Name: .$varname.br\n;
echo Variable Value: .$var.br\n;
}
showvar($test);
This is the only thing that works for me.I know it is messy
-Original Message-
From: Michael Sims [mailto:[EMAIL PROTECTED]
Sent: 05 May 2004 4:23 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Print a variable's name
Ahbaid Gaffoor wrote:
 

Thanks Ryan,
but what I want is to be able to pass any variable to a procedure and
have the variable name and value printed by the procedure.
Can this be done?
I'm trying to extend my library of debugging functions/procedures by
having a procedure which can be used to inspect a variable whenever
I call it.
   

This is a bit kludgy, but should work:
function showvar($varname) {
 if (!isset($GLOBALS[$varname])) { return; }
 echo Now showing: $varname\n;
 echo Value: .$GLOBALS[$varname].\n;
}
$s1 = Hello World;
showvar('s1');
HTH
 



Re: [PHP] Print a variable's name

2004-05-05 Thread Michal Migurski
 but what I want is to be able to pass any variable to a procedure and
 have the variable name and value printed by the procedure.

Because PHP passes arguments by value, you will be out of luck in most
cases -- by the time your debugging function sees the argument, it's no
longer tied to the calling scope. Michael Sims' example function works
only for variables in the global scope, which probably won't work for
anything complex enough to need its own debugging library.


 I'm trying to extend my library of debugging functions/procedures by
 having a procedure which can be used to inspect a variable whenever I
 call it.

You may find what you need in debug_backtrace(). Alternatively, just pass
the variable name along:
function echo_var($varname, $varvalue) {
printf(%s: %s\n, $varname, $varvalue);
}

...Which isn't much of an improvement over a plain old echo/print. And if
that's good enough for Brian Kernighan, I'd hope it's good enough for you.

:D

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Print a variable's name

2004-05-05 Thread Ahbaid Gaffoor
That's the way I ended up going
pass the name and value along :)
Not what I was hoping for, but it gets the job done, and it's only for 
debugging pruposes

thanks
Ahbaid.
Michal Migurski wrote:
but what I want is to be able to pass any variable to a procedure and
have the variable name and value printed by the procedure.
   

Because PHP passes arguments by value, you will be out of luck in most
cases -- by the time your debugging function sees the argument, it's no
longer tied to the calling scope. Michael Sims' example function works
only for variables in the global scope, which probably won't work for
anything complex enough to need its own debugging library.
 

I'm trying to extend my library of debugging functions/procedures by
having a procedure which can be used to inspect a variable whenever I
call it.
   

You may find what you need in debug_backtrace(). Alternatively, just pass
the variable name along:
function echo_var($varname, $varvalue) {
printf(%s: %s\n, $varname, $varvalue);
}
...Which isn't much of an improvement over a plain old echo/print. And if
that's good enough for Brian Kernighan, I'd hope it's good enough for you.
:D
-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
 



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Matt Matijevich
http://www.php.net/readdir

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



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Pooya Eslami
But how do I get all the .mp3 files? can I use *.mp3? and how ?

Matt Matijevich [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 http://www.php.net/readdir



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



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Matt Matijevich
on that page ther is examples

?php
if ($handle = opendir('.')) {
   while (false !== ($file = readdir($handle))) {
   if ($file != .  $file != ..) { //add your logic to see if
it is an .mp3 file right here, that can be done any number of ways
   echo $file\n;
   }
   }
   closedir($handle);
}
? 

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



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Pooya Eslami
That is exactly my question! how do I look for a .mp3 file?!
I tried
  if ($file != .  $file != ..  $file==*.mp3)
but it doesn't work!

Matt Matijevich [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 on that page ther is examples

 ?php
 if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != .  $file != ..) { //add your logic to see if
 it is an .mp3 file right here, that can be done any number of ways
echo $file\n;
}
}
closedir($handle);
 }
 ?

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



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Robert Cummings
On Sat, 2004-04-17 at 12:35, Pooya Eslami wrote:
 That is exactly my question! how do I look for a .mp3 file?!
 I tried
   if ($file != .  $file != ..  $file==*.mp3)
 but it doesn't work!

if( eregi( '\.mp3$', $file ) )

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Print out all the files in a directory

2004-04-17 Thread Pooya Eslami
Thank you Robert.

Robert Cummings [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Sat, 2004-04-17 at 12:35, Pooya Eslami wrote:
  That is exactly my question! how do I look for a .mp3 file?!
  I tried
if ($file != .  $file != ..  $file==*.mp3)
  but it doesn't work!

 if( eregi( '\.mp3$', $file ) )

 Cheers,
 Rob.
 -- 
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting  |
 | a powerful, scalable system for accessing system services  |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for   |
 | creating re-usable components quickly and easily.  |
 `'

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



Re: [PHP] Print page with default margins

2004-02-02 Thread Marek Kilimajer
Narcis Florea wrote:
Hi,
Hello,
I'm using Apache/PHP/MySQL in my business project
Thank you for using php!

My big problem now is: How can I print a page on a standard page format,
like Letter, left margin: 0.25 inch, etc.)
When I print, I must every time set page margin manually, and I want this
being made by php or javascript automatically on load page
Unfortunately, this is not php question. Try another list, likely css. I 
can help you only with this:

style type=text/css media=screen
!--
@import url(screen.css);
//--
/style
style type=text/css media=print
!--
@import url(print.css);
//--
/style
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PRINT QUESTION

2003-11-25 Thread Burhan Khalid
Dale Hersh wrote:
I know that in php there are a bunch of basic functions for opening a
connection to a printer and then handling the printer queue and so forth. I
would like to know how to take a string and echo that to the printer in php.
The printer functions only work under Windows. From 
http://www.php.net/printer :

These functions are only available under Windows 9.x, ME, NT4 and 2000.

So if you are on windows, you can try running the printer_write() 
example ( http://www.php.net/printer-write )

If you are not on Windows, one way you can print is to try some output 
redirection and see what kind of results you get, eg :

system(cat file.txt  lpt1);

were lpt1 is where your printer is connected. If your printer is 
connected directly to the computer, it is on lp1 (usually, lpt1 is the 
default printer port (parallel)). I think lpt1 stands for line printer 
terminal 1, but I'm not too sure about that.  There are probably better 
ways to do the same on other systems, but this is the quick example I 
could think of.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
---
Documentation is like sex: when it is good,
 it is very, very good; and when it is bad,
 it is better than nothing.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PRINT QUESTION

2003-11-25 Thread Jyry Kuukkanen
On Tue, 25 Nov 2003, Burhan Khalid wrote:

 Dale Hersh wrote:
  I know that in php there are a bunch of basic functions for opening a
  connection to a printer and then handling the printer queue and so forth. I
  would like to know how to take a string and echo that to the printer in php.
 
 The printer functions only work under Windows. From 
 http://www.php.net/printer :
 
 These functions are only available under Windows 9.x, ME, NT4 and 2000.
 
 So if you are on windows, you can try running the printer_write() 
 example ( http://www.php.net/printer-write )
 
 If you are not on Windows, one way you can print is to try some output 
 redirection and see what kind of results you get, eg :
 
 system(cat file.txt  lpt1);
 
 were lpt1 is where your printer is connected. If your printer is 
 connected directly to the computer, it is on lp1 (usually, lpt1 is the 
 default printer port (parallel)). I think lpt1 stands for line printer 
 terminal 1, but I'm not too sure about that.  There are probably better 
 ways to do the same on other systems, but this is the quick example I 
 could think of.



Hello,

I have printed plenty and regularly under Linux through CUPS by issuing:

exec(lpr -Pprinter_name file_to_print)

or

$ph = popen(lpr -Pprinter_name);
fwrite($ph, $data_to_print);
pclose($ph);


If you need fancy printout, it might be a good idea to produce PDF that is 
printed out, then. If this is what you want, take a look at 
http://dataxi.sourceforge.net and download solib-version.tar.gz that 
contains sopdf.php -- or dataxi-version.tar.gz for higher level PDF 
classes. You need www.pdflib.com (free lite version available) in order 
to use sopdf.php or it's derivants.

Cheers,

-- 
--Jyry
:-(C:-/C8-OC8-/C:-(

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



Re: [PHP] Print mysql errors

2003-10-21 Thread Eugene Lee
On Mon, Oct 20, 2003 at 05:28:08PM -0500, Joseph Bannon wrote:
: 
: How do you print the error message sent back from MySQL?
: 
: $resultCC = mysql_query($queryCC) or die(???);

Stop using stupid Perl syntax.

$res = mysql_query($query);
if ($res === false)
{
# print error to stdout
#
echo mysql_errno() . :  . mysql_error(). \n;
}

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



Re: [PHP] Print mysql errors

2003-10-20 Thread John W. Holmes
Joseph Bannon wrote:

How do you print the error message sent back from MySQL?

$resultCC = mysql_query($queryCC) or die(???);
??? = mysql_error()

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Print current and next three years

2003-09-24 Thread Marek Kilimajer
$current=date('Y');
for($i=0;$i4;$i++){
echo $current + $i;
}
Shaun wrote:

Hi,

I am trying to print the current and next three years in a form. Using the
following code I can only print 2000, 2001, 2002, 2003:
select name=start_date_year
 ?php
  $i = 1;
  while ($i = 4){
   if ($i + 1 == date(Y, strtotime($_GET[mysql_date]))){
echo 'option value='.date(Y, mktime(0, 0, 0, 0, 0, $i)).'
selected'.date(Y, mktime(0, 0, 0, 0, 0, $i)).'/option';
   } else {
echo 'option value='.date(Y, mktime(0, 0, 0, 0, 0,
$i)).''.date(Y, mktime(0, 0, 0, 0, 0, $i)).'/option';
   }
   $i++;
  }
 ?
/select
How can I get this code to start looping from the current year?

Thanks for your help

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


Re: [PHP] Print current and next three years

2003-09-24 Thread Becoming Digital
select name=start_date_year
?
  for( $i=0;$i3;$i++ ) {
$year = date( 'Y' )+$i;
echo 'option value='.$year.''.$year.'/option';
  }
?
/select

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message - 
From: Shaun [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 24 September, 2003 08:29
Subject: [PHP] Print current and next three years


Hi,

I am trying to print the current and next three years in a form. Using the
following code I can only print 2000, 2001, 2002, 2003:

select name=start_date_year
 ?php
  $i = 1;
  while ($i = 4){
   if ($i + 1 == date(Y, strtotime($_GET[mysql_date]))){
echo 'option value='.date(Y, mktime(0, 0, 0, 0, 0, $i)).'
selected'.date(Y, mktime(0, 0, 0, 0, 0, $i)).'/option';
   } else {
echo 'option value='.date(Y, mktime(0, 0, 0, 0, 0,
$i)).''.date(Y, mktime(0, 0, 0, 0, 0, $i)).'/option';
   }
   $i++;
  }
 ?
/select

How can I get this code to start looping from the current year?

Thanks for your help

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

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



RE: [PHP] Print help

2003-07-21 Thread Jay Blanchard
[snip]
What I would like to do is to make an optional page that can print
information to a specified printer.  Can PHP do this?
If so how???
[/snip]

Start by RTFM at http://us3.php.net/printer

HTH!

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



Re: [PHP] print vs heredoc

2003-07-08 Thread Philip Olson
 As to which is faster is does not really matter as the speed of echo
 print and heredoc is dictated by the connection speed to the
 requesting client. If this is a factor in your overall operation you
 can use output buffering to save the contents and output them at the end of
 your script.

Although really, heredoc can't be compared to either
echo or print, as it's just a string definition that
eventually will be printed.  So I guess you guys are
really comparing  vs heredoc?  And I agree that any
speed difference (if there is one) isn't a good reason
to choose when readablity may suffer.  So it all
depends on the situation, and the programmer.

 btw what would be nice is a print_raw command that does no
 parsing just sends the stuff :)
 (Would be good for template systems where you know there is no php
 hidden in there.) ... might gain a couple of micro seconds

I believe this is called breaking out of PHP mode
and into HTML mode, which can be done anywhere, at
any time.

Regards,
Philip


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



RE: [PHP] print vs. heredoc

2003-07-07 Thread Ralph Guzman
One way to get around having to edit backslashes is to echo using single
quotes. For example:

echo 'TABLE BORDER=0 WIDTH=100%TRTD' . $variable .
'/TD/TR/TABLE';





-Original Message-
From: Greg Donald [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 06, 2003 3:48 PM
To: Sparky Kopetzky
Cc: PHP General
Subject: Re: [PHP] print vs. heredoc


 I'm looking for opinions as to which is better, print or heredoc.

I prefer heredoc mostly because I do not enjoy editing html that is full
of 
backslashes.  I build up the html and only output anything at the end.
This 
allows for custom compression, whitespace stripping, etc.

 print makes the code layout look nice and eazy to debug, where heredoc
IS
 faster but makes the code look like a nightmare and I'm pretty picky
about
 what looks good.

Sounds like you already have your mind made up.


-- 
Greg Donald
http://destiney.com/



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




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



Re: [PHP] print vs heredoc

2003-07-07 Thread Joel Rees
 Hi, again!!

I thought I saw this post once already.

 I'm looking for opinions as to which is better/faster, print or heredoc.

Well, like the guy said before, it sounds like you've
pretty much already made up your mind.

I don't use heredocs everywhere, but when I have a fairly large block of
html with a small number of straight variable substitutions (no
conditionals, etc.), I sometimes find heredocs to be convenient, and a
lot easier to read in the source.

reformatted style=wrapped
 print makes the code layout look nice

Well, one of the purposes of a heredoc is to get the code out of the
content, yielding a cleaner, more readable layout. If that's not what
you're getting, you probably don't want to use heredocs.

 and eazy to debug,

If there's something you need to debug, heredocs are possibly not
indicated.

 where heredoc 
 IS faster but makes the code look like a nightmare with everything
 jammed against the left side of the code.

Not sure what you're saying. When I use heredocs, that is not the result,
by any stretch of the imagination. (Well, I'm not sure about the speed
business.)

 I'm pretty picky about what looks good and heredoc is a nightmare of
 horrors...
/reformatted

If that's the results you're getting, I'd say heredoc is probably not
appropriate for what you're trying to do.

-- 
Joel Rees, programmer, Kansai Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp


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



Re: [PHP] print vs heredoc

2003-07-07 Thread Tom Rogers
Hi,

Monday, July 7, 2003, 11:33:38 PM, you wrote:
SK Hi, again!!

SK I'm looking for opinions as to which is better/faster, print or heredoc.

SK print makes the code layout look nice and eazy to debug, where heredoc IS faster 
but makes the code look like a nightmare with everything jammed against the left side 
of the code. I'm pretty
SK picky about what looks good and heredoc is a nightmare of horrors...

SK Robin E. Kopetzky
SK Black Mesa Computers/Internet Services
SK www.blackmesa-isp.net

As to which is faster is does not really matter as the speed of echo
print and heredoc is dictated by the connection speed to the
requesting client. If this is a factor in your overall operation you
can use output buffering to save the contents and output them at the end of
your script.

btw what would be nice is a print_raw command that does no
parsing just sends the stuff :)
(Would be good for template systems where you know there is no php
hidden in there.) ... might gain a couple of micro seconds

-- 
regards,
Tom


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



Re: [PHP] print vs. heredoc

2003-07-06 Thread Greg Donald

 I'm looking for opinions as to which is better, print or heredoc.

I prefer heredoc mostly because I do not enjoy editing html that is full of 
backslashes.  I build up the html and only output anything at the end.  This 
allows for custom compression, whitespace stripping, etc.

 print makes the code layout look nice and eazy to debug, where heredoc IS
 faster but makes the code look like a nightmare and I'm pretty picky about
 what looks good.

Sounds like you already have your mind made up.


-- 
Greg Donald
http://destiney.com/



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



Re: [PHP] print html code

2003-07-02 Thread Leif K-Brooks
Karina S wrote:

Hello,

I want to make a php site which can generate a html code and display it on
the screen. (Display the code itself.)
I use htmlspecialchars() function. It works fine, but now I have to add
about 200 lines of static html code to print it out. If I put all of the
code in a string than it will appear in a single line. (Maybe it works, but
not nice)
How can I easy print out more lines of html code with php?
 

This has nothing to do with PHP, but try putting code and /code tags 
around the HTML.

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] print html code

2003-07-02 Thread Wendell Brown
On Wed, 2 Jul 2003 19:40:37 +0200, Karina S wrote:

I want to make a php site which can generate a html code and display it on
the screen. (Display the code itself.)

See if this will do what you want:

 http://us2.php.net/manual/en/function.highlight-string.php

or

 http://us2.php.net/manual/en/function.highlight-file.php


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



Re: [PHP] print html code

2003-07-02 Thread Jim Lucas
You could always use PLAINTEXT at the top of the screen.

Jim Lucas
- Original Message -
From: Wendell Brown [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Karina S [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 11:27 AM
Subject: Re: [PHP] print html code


 On Wed, 2 Jul 2003 19:40:37 +0200, Karina S wrote:

 I want to make a php site which can generate a html code and display it
on
 the screen. (Display the code itself.)

 See if this will do what you want:

  http://us2.php.net/manual/en/function.highlight-string.php

 or

  http://us2.php.net/manual/en/function.highlight-file.php


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




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



Re: [PHP] print html code

2003-07-02 Thread Leif K-Brooks
Jim Lucas wrote:

You could always use PLAINTEXT at the top of the screen.

And violate every single HTML standard.  AFAIK, plaintext was never a 
real tag.

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] print html code

2003-07-02 Thread Jim Lucas
So what, it would do what was requested.  :)

Jim Lucas
- Original Message -
From: Leif K-Brooks [EMAIL PROTECTED]
To: Jim Lucas [EMAIL PROTECTED]
Cc: Wendell Brown [EMAIL PROTECTED]; [EMAIL PROTECTED]; Karina
S [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 12:30 PM
Subject: Re: [PHP] print html code


 Jim Lucas wrote:

 You could always use PLAINTEXT at the top of the screen.
 
 And violate every single HTML standard.  AFAIK, plaintext was never a
 real tag.

 --
 The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.



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




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



Re: [PHP] print html code

2003-07-02 Thread Leif K-Brooks
In browsers that refuse to follow standards, maybe.  Breaking standards 
is a bad thing.
Jim Lucas wrote:

So what, it would do what was requested.  :)

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] print html code

2003-07-02 Thread Jeff Harris
On Jul 2, 2003, Karina S claimed that:

|Hello,
|
|I want to make a php site which can generate a html code and display it on
|the screen. (Display the code itself.)
|I use htmlspecialchars() function. It works fine, but now I have to add
|about 200 lines of static html code to print it out. If I put all of the
|code in a string than it will appear in a single line. (Maybe it works, but
|not nice)
|
|How can I easy print out more lines of html code with php?
|
|Thanks!
|

Make sure you're putting \n in the string, then print
nl2br(htmlspecialchars($string));

Use php's wordwrap() or find another word_wrap function then print
wordwrap(htmlspecialchars($string));

-- 
Registered Linux user #304026.
lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



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



Re: [PHP] print html code

2003-07-02 Thread Jim Lucas
well, tell me.  What browser follows the standards 100% ??
- Original Message -
From: Leif K-Brooks [EMAIL PROTECTED]
To: Jim Lucas [EMAIL PROTECTED]
Cc: Wendell Brown [EMAIL PROTECTED]; [EMAIL PROTECTED]; Karina
S [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 12:57 PM
Subject: Re: [PHP] print html code


 In browsers that refuse to follow standards, maybe.  Breaking standards
 is a bad thing.
 Jim Lucas wrote:

 So what, it would do what was requested.  :)
 

 --
 The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent of
the law.



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




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



Re: [PHP] print html code

2003-07-02 Thread Jeff Harris
On Jul 2, 2003, Jim Lucas claimed that:

|well, tell me.  What browser follows the standards 100% ??

The same one that is 100% bug free?

-- 
Registered Linux user #304026.
lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



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



Re: [PHP] print html code

2003-07-02 Thread Leif K-Brooks
Jim Lucas wrote:

well, tell me.  What browser follows the standards 100% ??
 

Most likely none.  That doesn't mean you should violate the standards 
for absolutley no reason, though!  Future browsers will most likely drop 
plaintext.

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] print html code

2003-07-02 Thread John Nichel
Jim Lucas wrote:
well, tell me.  What browser follows the standards 100% ??
Yeah...that's the attitude...if none of the existing browsers follow 
standards, then it must be okay for us to break them too.

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


Re: [PHP] print array

2003-06-27 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 27 Jun 2003 at 12:10,
lines prefixed by '' were originally written by you.
 I would off course like it even better when i was able to print to the
 values
 (word and number) in an HTML table structure, or each new word on a
 new line
 for instance, and without the [ ]  and =. Is this possible, and if
 so, how
 do i solve this?

See www.php.net/foreach

echo TABLE\n;
foreach($yourarray as $word=$count){
echo TRTD$word/TDTD$count/TD/TR\n;
}
echo /TABLE\n;

HTH

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



RE: [PHP] Print '\n' not working

2003-06-25 Thread Jay Blanchard
[snip]
I am using PHP 4, Apache, but the '\n' is not going to the next line
during
a print.  Has anyone else encountered this anamoly.
[/snip]

show us the code...and what are you using to view the output file?

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



Re: [PHP] Print '\n' not working

2003-06-25 Thread Adam Voigt
You do know that the \n will only show up in View Source
of an HTML page right? If you want it to show up in a regular
browser window, you need br.

On Wed, 2003-06-25 at 13:05, Koch-1 Linda wrote:
 I am using PHP 4, Apache, but the '\n' is not going to the next line during
 a print.  Has anyone else encountered this anamoly.
-- 
Adam Voigt ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


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



RE: [PHP] Print '\n' not working

2003-06-25 Thread Koch-1 Linda

Adam caught my error.  I was not thinking correctly.

Thanks
-Original Message-
From: Adam Voigt [mailto:[EMAIL PROTECTED]

You do know that the \n will only show up in View Source
of an HTML page right? If you want it to show up in a regular
browser window, you need br.

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



RE: [PHP] Print '\n' not working

2003-06-25 Thread Dan Joseph
Hi,

 I am using PHP 4, Apache, but the '\n' is not going to the next 
 line during
 a print.  Has anyone else encountered this anamoly.

in the case of:

echo 'blah\n';

I've noticed it doesn't work.

In the case of:

echo blah\n;

I've noticed it does work.  The difference?  ' and .  

-Dan Joseph

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



Re: [PHP] Print '\n' not working

2003-06-25 Thread Chris Shiflett
--- Koch-1 Linda [EMAIL PROTECTED] wrote:
 I am using PHP 4, Apache, but the '\n' is not going to the next
 line during a print.

There are probably two issues here. One is that anything in single quotes gets
translate literally, so '\n' will output \n whereas \n will output a newline
character.

The other issue is that newlines are not interpreted by browsers unless
something like the pre tag is used or the content type is plain text. In the
case of HTML documents, you need a br (or br / for XHTML). There is a PHP
function that can help with this, nl2br().

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



Re: [PHP] print all variables

2003-06-18 Thread Adam Voigt
print_r($_POST) OR print_r($_GET)


On Wed, 2003-06-18 at 11:51, Matt Palermo wrote:
 Could anyone tell me how to print all the variables and values from a submitted 
 form, so that I can check them? 
 
 Thanks,
 
 Matt 
-- 
Adam Voigt ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


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



Re: [PHP] print all variables

2003-06-18 Thread Lars Torben Wilson
On Wed, 2003-06-18 at 08:51, Matt Palermo wrote:
 Could anyone tell me how to print all the variables and values from a submitted 
 form, so that I can check them? 
 
 Thanks,
 
 Matt 

  print_r($_REQUEST);

...or, depending on the method your form is using, one of:

  print_r($_POST);
  // or
  print_r($_GET);


This information, for the record, is readily available in the manual.



Good luck,

Torben


-- 
 Torben Wilson [EMAIL PROTECTED]+1.604.709.0506
 http://www.thebuttlesschaps.com  http://www.inflatableeye.com
 http://www.hybrid17.com  http://www.themainonmain.com
 - Boycott Starbucks!  http://www.haidabuckscafe.com -




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



Re: [PHP] print $array[$i][0] pukes

2003-03-06 Thread David T-G
Leif, et al --

...and then Leif K-Brooks said...
% 
% print $i :: {$manilist[$i][0]}\n;

Aha!  Perfect.  Here I'd been trying such things with the leading $ on
the *outside* of the braces.

Thanks, all, for the help!


Back on the 'net after a great all-night storm (which in fact hasn't
stopped and is really doing the sheet-of-tin-booming thing),
:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] print $array[$i][0] pukes

2003-03-06 Thread Ernest E Vogelsinger
At 10:44 06.03.2003, David T-G said:
[snip]
...and then Leif K-Brooks said... 
% 
% print $i :: {$manilist[$i][0]}\n;
Aha! Perfect. Here I'd been trying such things with the leading $ on 
the *outside* of the braces.
[snip] 

Try to see it this way: $manilist[$i][0] is a PHP expression, thus needs to
be put in curly braces _as_a_whole_ within a string.

It doesn't hurt to use curly quotes even if they're not necessary - it's
just the same as with using brackets in expression to clarify operator
precedence: with brackets, you don't have to fear any performance impact
and gain the clarity of the evaluation sequence; with curly quotes, you
gain the correct result :-)


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] print $array[$i][0] pukes

2003-03-06 Thread David T-G
Ernest, et al --

...and then Ernest E Vogelsinger said...
% 
% At 10:44 06.03.2003, David T-G said:
% [snip]
% ...and then Leif K-Brooks said... 
% % 
% % print $i :: {$manilist[$i][0]}\n;
% Aha! Perfect. Here I'd been trying such things with the leading $ on 
% the *outside* of the braces.
% [snip] 
% 
% Try to see it this way: $manilist[$i][0] is a PHP expression, thus needs to
% be put in curly braces _as_a_whole_ within a string.

Right.  What I hadn't seen before is that

  $manilist[$i]

is NOT evaluated like

  {$manilist}[$i]

but as

  {$manilist[$i]}

and so that's why I was putting the $ outside the {}.  Some things about
php aren't quite as perl-ish as others :-)


Thanks  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] print $array[$i][0] pukes

2003-03-05 Thread Chris Wesley
On Wed, 5 Mar 2003, David T-G wrote:

   $m = count($manilist) ;
   for ( $i=0 ; $i$m ; $i++ )
 { print $i :: $manilist[$i][0]\n ; }

 I simply get 'Array[0]' out for each inner..  Clearly php is seeing that
 $manilist[$i] is an array, telling me so, and then happily printing the
 [0]; how do I get to the value itself without having to use a temporary
 array?

Actually, it's literally printing [0] after it prints Array.  PHP is
detecting that $manilist (not $manilist[0]) is an array (for which it
prints Array), then you get a literal [0]  afterwards because you put
it all within quotes.

If you print this way, you'll get what you want:

print $i ::  . $manilist[$i][0] . \n;

HTH,
~Chris


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



Re: [PHP] print $array[$i][0] pukes

2003-03-05 Thread David T-G
Chris --

...and then Chris Wesley said...
% 
% On Wed, 5 Mar 2003, David T-G wrote:
% 
%$m = count($manilist) ;
%for ( $i=0 ; $i$m ; $i++ )
%  { print $i :: $manilist[$i][0]\n ; }
...
% 
% Actually, it's literally printing [0] after it prints Array.  PHP is

Right.


% detecting that $manilist (not $manilist[0]) is an array (for which it
% prints Array), then you get a literal [0]  afterwards because you put
% it all within quotes.

A...


% 
% If you print this way, you'll get what you want:
% 
% print $i ::  . $manilist[$i][0] . \n;

OK.  That works, though it isn't pretty.  Is there any way I can avoid
doing the dot dance?  I'd rather something like

  print $i :: ${manilist[$i]}[0]\n ;

(which I know to not work! :-) than to have to open and close; that's
just not very clean to me.  I'm the sort who doesn't switch in and out of
php parsing, either :-)


% 
%   HTH,
%   ~Chris


Thanks  TIA  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] print $array[$i][0] pukes

2003-03-05 Thread Leif K-Brooks
print $i :: {$manilist[$i][0]}\n;

David T-G wrote:

OK.  That works, though it isn't pretty.  Is there any way I can avoid
doing the dot dance?  I'd rather something like
 print $i :: ${manilist[$i]}[0]\n ;

(which I know to not work! :-) than to have to open and close; that's
just not very clean to me.  I'm the sort who doesn't switch in and out of
php parsing, either :-)
 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] Print text and image in the same page.

2002-12-15 Thread Chris Shiflett
--- Naif M. Al-Otaibi [EMAIL PROTECTED] wrote:
 I try to print some information (text and image) that I
 retrieve from an oracle DB, but I got the image printed
 as binary junk. When I put the line that print the image
 in a  html image tag, I got a red square with X inside.
 What can I do to solve this problem?

This is really just an HTML question. The img tag has an
attribute called src that should be given a URL as a value.
The URL should be an image. For example:

img src=http://www.php.net/gifs/php_snow.gif;

On the other hand, if you want to dump the raw image to the
browser and expect it to render it properly, you must tell
it that you are sending an image. For example:

header(Content-Type: image/gif);

Chris

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




RE: [PHP] Print page

2002-08-29 Thread Jay Blanchard

[snip]
I'm using PHP to generate some report for printing.
But when I print report from IE 5.0 browser, in the bottom of page
IE prints URL of page.
Can I remove it ?
[/snip]

Only in individual browser settings (like IE, File-Page Setup-Clear the
Header and Footer boxes). There is no way to control this with PHP. Each
browser is different on how this is handled.

HTH!

Jay

***
* Central Texas PHP Developers Group  *
* San Antonio, Austin, San Marcos, New Braunfels, *
* Seguin, Boerne, Blanco, the Hill Country*
* Interested? *
* Contact [EMAIL PROTECTED] *
***



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




RE: [PHP] Print page

2002-08-29 Thread Collins, Robert

yes, but that is a browser function not php 
goto file - page setup - then remove the header and footer data

Robert W. Collins II
Webmaster
New Orleans Regional Transit Authority
Phone : (504) 248-3826
Fax: (504) 248-3866
Email : [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 



-Original Message-
From: Rosen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 11:29 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Print page


Hi,
I'm using PHP to generate some report for printing.
But when I print report from IE 5.0 browser, in the bottom of page
IE prints URL of page.
Can I remove it ?


Thanks,
Rosen



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



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




Re: [PHP] Print page

2002-08-29 Thread @ Edwin


Hi,
I'm using PHP to generate some report for printing.
But when I print report from IE 5.0 browser, in the bottom of page
IE prints URL of page.
Can I remove it ?

Yes. Click on "File" - "Page settings..." then find "Footer" and you'll 
see something like this:

  ubd

Take away the "u", print again (or preview) and see what happens. Check 
help F1 for more info...

- E




Thanks,
Rosen



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





_
$B%&%#%k%9%a!<%k!"LBOG%a!<%kBP:v$J$i(B MSN Hotmail http://www.hotmail.com/JA


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


Re: [PHP] Print page

2002-08-29 Thread Rosen

Thanks very much 
Rosen

Jay Blanchard [EMAIL PROTECTED] wrote in message
003601c24f79$7ed376a0$8102a8c0@000347D72515">news:003601c24f79$7ed376a0$8102a8c0@000347D72515...
 [snip]
 I'm using PHP to generate some report for printing.
 But when I print report from IE 5.0 browser, in the bottom of page
 IE prints URL of page.
 Can I remove it ?
 [/snip]

 Only in individual browser settings (like IE, File-Page Setup-Clear the
 Header and Footer boxes). There is no way to control this with PHP. Each
 browser is different on how this is handled.

 HTH!

 Jay

 ***
 * Central Texas PHP Developers Group  *
 * San Antonio, Austin, San Marcos, New Braunfels, *
 * Seguin, Boerne, Blanco, the Hill Country*
 * Interested? *
 * Contact [EMAIL PROTECTED] *
 ***





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




Re: [PHP] Print page

2002-08-29 Thread Rosen

Thanks very much 
Rosen


Robert Collins [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 yes, but that is a browser function not php
 goto file - page setup - then remove the header and footer data

 Robert W. Collins II
 Webmaster
 New Orleans Regional Transit Authority
 Phone : (504) 248-3826
 Fax: (504) 248-3866
 Email : [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]



 -Original Message-
 From: Rosen [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 29, 2002 11:29 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Print page


 Hi,
 I'm using PHP to generate some report for printing.
 But when I print report from IE 5.0 browser, in the bottom of page
 IE prints URL of page.
 Can I remove it ?


 Thanks,
 Rosen



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





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




  1   2   >