Re: [PHP] echo vs printf

2001-07-17 Thread hassan el forkani

whereas to echo it you'd have to concatenate the string. false
you don't have to concat strings with echo you can print vars the same way as print

regards

16/07/01 17:48:43, Steve Brett [EMAIL PROTECTED] wrote:

i seem to remember reading somewhere that print acts like (is) a function,
presumably returning false if  it cannot print to screen, whereas echo just
dumps it.

also you can drop vars in print like

print you have $points points;

whereas to echo it you'd have to concatenate the string.

Steve


Don Read [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 On 16-Jul-01 brother wrote:
  Why should I use printf instead of echo and vice versa?
 

 printf print-formated

 $a=12.3456;

 echo $a, 'BR';
 printf('%1.2fBR', $a);

 12.3456BR
 12.34BR

  As for today I use printf mostly but I don't know why.

 You prolly mean print; There may be some minor differences from echo,
 but i've never seen 'em.
 (i think they threw print in PHP to keep JAPHs happy).

 Regards,
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] echo vs printf

2001-07-16 Thread Don Read


On 16-Jul-01 brother wrote:
 Why should I use printf instead of echo and vice versa? 
 

printf print-formated

$a=12.3456;

echo $a, 'BR';
printf('%1.2fBR', $a);

12.3456BR
12.34BR

 As for today I use printf mostly but I don't know why.

You prolly mean print; There may be some minor differences from echo,
but i've never seen 'em. 
(i think they threw print in PHP to keep JAPHs happy).

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] echo vs printf

2001-07-16 Thread Steve Brett

i seem to remember reading somewhere that print acts like (is) a function,
presumably returning false if  it cannot print to screen, whereas echo just
dumps it.

also you can drop vars in print like

print you have $points points;

whereas to echo it you'd have to concatenate the string.

Steve


Don Read [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 On 16-Jul-01 brother wrote:
  Why should I use printf instead of echo and vice versa?
 

 printf print-formated

 $a=12.3456;

 echo $a, 'BR';
 printf('%1.2fBR', $a);

 12.3456BR
 12.34BR

  As for today I use printf mostly but I don't know why.

 You prolly mean print; There may be some minor differences from echo,
 but i've never seen 'em.
 (i think they threw print in PHP to keep JAPHs happy).

 Regards,
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] echo vs printf

2001-07-16 Thread rm

Actually, you can do the same thing with echo.

echo you have $points points;

As I understand it, echo is not a function it's a
language something or other, supposedly it runs
slightly faster than print given the same output.

however, given it's Monday, I could be wrong.

rm

 
 also you can drop vars in print like
 
 print you have $points points;
 
 whereas to echo it you'd have to concatenate the
 string.
 


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] echo vs printf

2001-07-16 Thread scott [gts]

from the manual:
[print is a language construct [EMAIL PROTECTED]]
The print() function returns a boolean indicating the status of the call. If the
write was successful, print() returns 1. If not, it returns 0. This can be used to
detect when the client has closed the connection, and appropriate measures taken. The
builtin echo does not provide this same service.


can anyone else think of any other difference between
print and echo ?

i use print, becuase that's what i'm used to...
but i'd be curious to find out if there really
is any significant differences between the way
echo and print both work.


 -Original Message-
 From: Steve Brett [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 16, 2001 11:49 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] echo vs printf


 i seem to remember reading somewhere that print acts like (is) a function,
 presumably returning false if  it cannot print to screen, whereas echo just
 dumps it.

 also you can drop vars in print like

 print you have $points points;

 whereas to echo it you'd have to concatenate the string.

 Steve


 Don Read [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
  On 16-Jul-01 brother wrote:
   Why should I use printf instead of echo and vice versa?
  
 
  printf print-formated
 
  $a=12.3456;
 
  echo $a, 'BR';
  printf('%1.2fBR', $a);
 
  12.3456BR
  12.34BR
 
   As for today I use printf mostly but I don't know why.
 
  You prolly mean print; There may be some minor differences from echo,
  but i've never seen 'em.
  (i think they threw print in PHP to keep JAPHs happy).
 
  Regards,
  --
  Don Read   [EMAIL PROTECTED]
  -- It's always darkest before the dawn. So if you are going to
 steal the neighbor's newspaper, that's the time to do it.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] echo vs printf

2001-07-16 Thread Kent Sandvik

As I understand it, echo is not a function it's a
language something or other, supposedly it runs
slightly faster than print given the same output.
 
?php
class xTimer{
var $time_start;
var $time_delta; 

function Start(){
$this-time_start = $this-GetMicroTime();
}

function Stop(){
$time_end = $this-GetMicroTime();
$this-time_delta = $time_end - $this-time_start;
return $this-time_delta;
}

function GetMicroTime(){
list($usec, $sec) = explode( , microtime());
return ((float)$usec + (float)$sec);
}
}

print echo vs print testbr\n;
$string = foo ;
$iter = 100;
$t = new xTimer;
$t-Start();
for($i = 0; $i  $iter; $i++){
print $string;
}
$print_time = $t-Stop();

$t-Start();
for($i=0; $i  $iter; $i++){
echo $string;
}
$echo_time = $t-Stop();

print \nbrprint printing $iter times: $print_timebr\n;
print \nbrecho printing $iter times: $echo_timebr\n;
?

Results:
Test1:
print printing 100 times: 2.829174041748
echo printing 100 times: 3.683454990387

Test2:
print printing 100 times: 3.131462931633
echo printing 100 times: 2.8942189216614

Test3:
print printing 100 times: 5.127711057663
echo printing 100 times: 5.5264019966125

HW, Dell rackmount Server, dual CPU running Linux 2.2.16.

--Kent


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] echo vs printf

2001-07-16 Thread rm


I don't know what to say, my comment was based on

http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

note the author.

I ran your code in both windows and linux and got
faster speeds, on a regular basis, for echo. That
said, the speed differences were not great(minor is a
good description), I think the greatest was half a sec
for 1 million loops.

rm

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]