php-windows Digest 22 Apr 2005 21:51:24 -0000 Issue 2642

Topics (messages 25894 through 25901):

Re: Automatic word documents printing failure
        25894 by: Nick

Re: Jaw Breaker - What's the ansewer?
        25895 by: JC Botha
        25897 by: graeme

php test suite for windows
        25896 by: Xin Huang

How do I get php to repeat and action every day?
        25898 by: Maxwell Brodie
        25899 by: Mike

Problem 2 of 2 - variables by reference
        25900 by: lists

Problem 1 of 2 - Sessions not working
        25901 by: lists

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
on a network printer, he doesnt want to print

on a local printer, he only wants to print the last file


any help for this?
thanks

--- End Message ---
--- Begin Message ---
Hi Jin,

Yes that also buged me, had no idea why it does that. I also battled
with this one for a while. Perhaps there are more on the mailing list
that got some info on this technical point.

Thanks for your intrest!

Chris

On 4/21/05, Wu, Jin Yong <[EMAIL PROTECTED]> wrote:
> 
> It's so interesting. At the beginning, I missed the statement "$x =
> round($x, 2) + 0.01;",
> and can't get corrent answer.Then, I trace the $x value, I found its value
> was changed to have
> 13 decimal places from 4.43 on. Could you explain it for me?thank you ahead.
> 
> -----Original Message-----
> From: JC Botha [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 20, 2005 19:50 PM
> To: graeme
> Cc: [email protected]
> Subject: Re: [PHP-WIN] Re: Jaw Breaker - What's the ansewer?
> 
> Well done Graeme!
> 
> Posted below is what I used to generate the asnwer, I myself had
> dificulty to get it. Let me know if you used another method.
> 
> The Source Code
> ==================================================
> <?php
> function f($c) {
>     $c++;
>     if ($c % 2) { return f($c); }
>     return $c++;
>   }
> 
>   function g($n) {
>     for ($i=1;$i<10;$i++) {
>       $n = f($n*$i);
>     }
>     return ($n);
>   }
>       $x = 0.00;
>    while ($x < 10){
> 
>       $x = round($x, 2) + 0.01;
>       $l = (g($x));
> 
>       if ($l == 4277108){
>               echo("<font color='red'>:: x = $x : $l</font> <br/>");
>        }
>       //echo ("> $x : $l<br/>");
> 
>    }
> 
> ?>
> 
> =================================================
> 
> On 4/20/05, graeme <[EMAIL PROTECTED]> wrote:
> > Yes it is an issue with floating point numbers since:
> >
> > 8.35 will give the answer but if you increment by .01 in a loop then you
> > will not get the answer, when it is on 8.35. However, increment by 0.001
> > then 8.35 will provide the correct answer. It's all to do with how in
> > calculates 0.01 in binary, a rational fraction in binary.
> >
> > graeme.
> >
> > JC Botha wrote:
> >
> > >It is possible, and "10.642868165785" is incorrect. The question says
> > >"$x is a number between 1 and 10 and has 2 decimal places."
> > >
> > >Try again, if more try then I will post the source code that generates
> > >the asnwer?
> > >
> > >
> > >
> > >On 4/20/05, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >>JC Botha wrote:
> > >>
> > >>
> > >>>The following is a section of PHP code (see Apache.org and PHP.net).
> > >>>
> > >>>  function f($c) {
> > >>>    $c++;
> > >>>    if ($c % 2) { return f($c); }
> > >>>    return $c++;
> > >>>  }
> > >>>
> > >>>  function g($n) {
> > >>>    for ($i=1;$i<10;$i++) {
> > >>>      $n = f($n*$i);
> > >>>    }
> > >>>    return ($n);
> > >>>  }
> > >>>
> > >>>  print(g($x));
> > >>>
> > >>>What is the smallest value that $x can have if 4277108 is outputted to
> > >>>the screen after running this code?
> > >>>$x is a number between 1 and 10 and has 2 decimal places.
> > >>>
> > >>>
> > >>it's not a jawbreaker, it's impossible IMO.
> > >>f() always returns the number if it's uneven, or if it's even, it
> > >>returns (n+1). So, it always returns uneven. which means the result of
> > >>g() can *never* be even.
> > >>
> > >>[[side note:
> > >>unless "return $c++;" does first add 1 to it before returning, but I
> > >>think it doesn't, since it's a postincrement operator.
> > >>]]
> > >>
> > >>--
> > >>PHP Windows Mailing List (http://www.php.net/)
> > >>To unsubscribe, visit: http://www.php.net/unsub.php
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> >
> > --
> > Experience is a good teacher, but she sends in terrific bills.
> >
> > Minna Antrim
> >
> >
> 
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
In essence it's how decimal fractions are represented in binary

in binary

.1 is a half
.01 is a quarter
.001 is an eighth
and so on.

The binary representation of decimal .1 is not an exact value...

.0001  = 0.0625
.00011 =  .09375
.000110011 = .099609375
.0001100110011 = .0999755859375

As you can see it is a recurring number that will approximate to .1 (.01 is a similar value, try it for yourself) So a computer, which works in binary can only get an approximation to the decimal number .1. Whilst PHP has checks built in to locate this error there are ways to circumvent these checks, or at least make it harder for PHP to spot the errors that do creep in. My solution was to increment the loop by .001, the extra level of significant digits triggers off sufficient error checking, your specific call to the round function also triggers of extra error checking.

I hope that helps,

graeme


JC Botha wrote:

Hi Jin,

Yes that also buged me, had no idea why it does that. I also battled
with this one for a while. Perhaps there are more on the mailing list
that got some info on this technical point.

Thanks for your intrest!

Chris

On 4/21/05, Wu, Jin Yong <[EMAIL PROTECTED]> wrote:


It's so interesting. At the beginning, I missed the statement "$x =
round($x, 2) + 0.01;",
and can't get corrent answer.Then, I trace the $x value, I found its value
was changed to have
13 decimal places from 4.43 on. Could you explain it for me?thank you ahead.

-----Original Message-----
From: JC Botha [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 20, 2005 19:50 PM
To: graeme
Cc: [email protected]
Subject: Re: [PHP-WIN] Re: Jaw Breaker - What's the ansewer?

Well done Graeme!

Posted below is what I used to generate the asnwer, I myself had
dificulty to get it. Let me know if you used another method.

The Source Code
==================================================
<?php
function f($c) {
   $c++;
   if ($c % 2) { return f($c); }
   return $c++;
 }

 function g($n) {
   for ($i=1;$i<10;$i++) {
     $n = f($n*$i);
   }
   return ($n);
 }
     $x = 0.00;
  while ($x < 10){

     $x = round($x, 2) + 0.01;
     $l = (g($x));

     if ($l == 4277108){
             echo("<font color='red'>:: x = $x : $l</font> <br/>");
      }
     //echo ("> $x : $l<br/>");

  }

?>

=================================================

On 4/20/05, graeme <[EMAIL PROTECTED]> wrote:


Yes it is an issue with floating point numbers since:

8.35 will give the answer but if you increment by .01 in a loop then you
will not get the answer, when it is on 8.35. However, increment by 0.001
then 8.35 will provide the correct answer. It's all to do with how in
calculates 0.01 in binary, a rational fraction in binary.

graeme.

JC Botha wrote:



It is possible, and "10.642868165785" is incorrect. The question says
"$x is a number between 1 and 10 and has 2 decimal places."

Try again, if more try then I will post the source code that generates
the asnwer?



On 4/20/05, M. Sokolewicz <[EMAIL PROTECTED]> wrote:




JC Botha wrote:




The following is a section of PHP code (see Apache.org and PHP.net).

function f($c) {
  $c++;
  if ($c % 2) { return f($c); }
  return $c++;
}

function g($n) {
  for ($i=1;$i<10;$i++) {
    $n = f($n*$i);
  }
  return ($n);
}

print(g($x));

What is the smallest value that $x can have if 4277108 is outputted to
the screen after running this code?
$x is a number between 1 and 10 and has 2 decimal places.




it's not a jawbreaker, it's impossible IMO.
f() always returns the number if it's uneven, or if it's even, it
returns (n+1). So, it always returns uneven. which means the result of
g() can *never* be even.

[[side note:
unless "return $c++;" does first add 1 to it before returning, but I
think it doesn't, since it's a postincrement operator.
]]

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









--
Experience is a good teacher, but she sends in terrific bills.

Minna Antrim




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







-- Experience is a good teacher, but she sends in terrific bills.

Minna Antrim


--- End Message ---
--- Begin Message --- I installed php 4.3.11 on my windows xp sp2 box and was able to do some simple testing following the documentation. I was wondering where I can find more thorough test suite for PHP on windows? It's not in the downloaded package.

Thanks,

Xin
--- End Message ---
--- Begin Message ---
Hello,

I wish to have a php file repeat every day at a certain time, is there any 
way to do this?

Thank you! 

--- End Message ---
--- Begin Message ---
> Hello,
> 
> I wish to have a php file repeat every day at a certain time, 
> is there any way to do this?
> 
Yes and no.

PHP by itself can't do this. But you can easily set up a crontab
(http://www.google.com/search?hl=en&lr=&q=crontab&btnG=Search) or a windows
scheduled task pending on your server.

Then just call 

php page.php

to execute it. Most hosts let you set up at least a few crontabs as long as
they're not running every minute or two.

-M

--- End Message ---
--- Begin Message ---
Gentlefolk,

There is a problem getting referenced variables updated on my system.� But it 
doesn't apply to all of them.� Win2K SP4, IIS 5.?, PHP v4.3.5, MySQL v3.23.49 . 
. . does that cover the basics?

f_get_profile($uid, $user, $laston, $birth);
calling
function f_get_profile($uid, &$user, &$laston, &$birth){
��� handling and updating code here
}

seems to work, while

f_get_prefs($uid, $color, $style, $body, $act);
calling
function f_get_prefs($uid, &$color, &$style, &$body, &$act){
��� handling and updating code here
}

doesn't work at all.� I though perhaps I was using unset() improperly, but that 
doesn't seem to be the case.� In light of the session problem I've been having 
(Problem 1 of 2), I suppose it's a PHP.INI problem, but I'm at wit's send 
trying to ascertain where it might lie.� I'd appreciate any guidance I might 
get toward a resolution.




Make a good day . . .

 . . barn

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Truth is realized in an instant; the Act is practiced step by step. - Zen 
saying
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- End Message ---
--- Begin Message ---
Gentlefolk,

I'm having trouble getting session functionality.� Win2K SP4, IIS 5.?, PHP 
v4.3.5, MySQL v3.23.49 . . . does that cover the basics?

My PHP.INI file appears to be properly configured for session usage - at least, 
it is set according to what document specs I've been able to find.� I first 
encountered this a few weeks ago while working on a database app.� In that 
case, I finally gave up and reworked the app so that entire pages became 
functions that I could call from the index page - even include files could not 
access session variables {sigh /}.� However, now I need to implement a chat app 
- we've selected PHPOpenChat, v3.0.1 - that makes use of sessions, and I cannot 
find a way to make session data available.� Whenever I try to load a page that 
has session declarations, IE (v6.0.2800.1106) provides, "CGI Timeout.� The 
specified CGI Application exceeded the allowed time for processing.� The server 
has deleted the process," and Firefox (v1.0.1) does the same.

In trying to find a way for this to work, I've tried every way listed in the 
PHP manual�of establishing a session and setting/calling session variables.� In 
the simplest incarnation, the calling page is simply
<?
��� session_start();
��� $_SESSION["testvar"]="eureka";
 . . code to create a form with a submit button to call next page . . .
?>
and the called page is even simpler,
<?
��� session_start();
��� $a=$_SESSION["testvar"];
��� echo "a=$a<br />";
?>

I've tried those two pages with every syntactical variant I've been able to 
find, but can't make any of 'em work.� Ok, that, to me, implies that there's 
something wrong with my PHP.INI file in regard to sessions, but I cannot for 
the life of me determine what.� I've looked at that file so long now that I 
probably couldn't see an error if it were in the Cyrillic alphabet {sigh /}.

So, does anyone have any ideas on what might be wrong?� Or should I just shoot 
myself and be done with it?

'Preciate any help forthcoming.




Make a good day . . .

 . . barn

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is no love sincerer than the love of food. - George Bernard Shaw
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- End Message ---

Reply via email to