php-windows Digest 29 Jul 2007 21:45:32 -0000 Issue 3296

Topics (messages 28279 through 28280):

Re: Arrays past to functions
        28279 by: Jeff White

Error reporting
        28280 by: Bruce Cowin

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 ---
Hello Jacob,

This may be what you're looking for:

<?php

function compute_salestax ($Amount, $Rates = array())
{
        foreach($Rates as $State => $Rate)
        { 
                $Ret[$State] = $Amount  * ($Rate/100); 
        }
        return $Ret;
}

echo "Payment: " . $payment = 1500;
$taxRates = array("CA" => 5 , "WA" =>  7, "OR" => 8);
$taxresults = compute_salestax ($payment, $taxRates);
foreach($taxresults as $state => $value)
{
 print "<br />Tax = " . sprintf("%01.2f", round($value, 2)) . " in $state.";
}

?>

Browser output results:

Payment: 1500
Tax = 75.00 in CA.
Tax = 105.00 in WA.
Tax = 120.00 in OR.

I hope this helps!!

Jeff White





-----Original Message-----
From: Jacob Bergman [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 27, 2007 2:07 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] Arrays past to functions

Thanks a bunch guys, I'm out for the day, I will pick this back up on
Monday, have a great weekend.

Jacob Bergman
Network Technician
Pullman School District #267
(509) 432-4012
[EMAIL PROTECTED]

-----Original Message-----
From: Niel Archer [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 27, 2007 11:03 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Arrays past to functions

Hi Jacob

Sorry, my fault entirely. I wrote it in a hurry after copy/pasting your
example. I didn't change the variable names properly or test it.

I still haven't been able to test, but this should work better now.

function compute_salestax ($Amount , $State)
{
    $taxRate = array("CA" => 5 , "WA" =>  7, "OR" => 8);
    return $Amount  * $taxRate($State);
}

$payment = 1500;
$locale = 'CA';
print "Tax on $amount in $locale is " . compute_salestax ($payment ,
$locale);


--
Niel Archer

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

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

--- End Message ---
--- Begin Message ---
I originally sent this to the general list with no replies.  As I'm it
concerns writing to the Windows event log, I thought I'd try my luck on
this list.

I'm running PHP 5.1 on IIS.  My dev environment is all local on my
machine.  My php.ini has the following error reporting settings:

error_reporting  =  E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
error_log = syslog

To test, I've written a little script that divides by 0.  When I run
the script from the command line, I get entries in my Event Log as
expected, but if I load the page into my browser (Firefox), no error
is
reported in the Event Log.  

I've checked http://www.php.net/manual/en/ref.errorfunc.php but can't
find anything there.  I figure I must be missing something pretty
obvious but not sure what it is.  The script and logged error from the
command line are below.  Thanks for any help.

script:
<html>
<title><head></head></title>
<body>
<?php

        $a = 5;
        $b = 0;
        $c = $a / $b;
        echo $c;
?>
</body>
</html>

logged error from command line:
The description for Event ID ( 2 ) in Source ( PHP-5.1.2 ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. You may be able to use the /AUXSOURCE= flag to retrieve this
description; see Help and Support for details. The following
information
is part of the event: php[2132], PHP Warning:  Division by zero in
C:\Inetpub\wwwroot\PHP\Testing\error.php on line 11.

Regards,

Bruce


Regards,

Bruce

--- End Message ---

Reply via email to