php-general Digest 12 Oct 2007 17:10:14 -0000 Issue 5069
Topics (messages 263131 through 263156):
Re: preg_match_all Help
263131 by: Jim Lucas
263135 by: admin.buskirkgraphics.com
263140 by: Richard Heyes
263141 by: Al
Compose MP3 from a php enabled flash page.
263132 by: John Taylor-Johnston
263156 by: Tom Ray [Lists]
Re: Classes - Dumb question
263133 by: Larry Garfield
263134 by: Nathan Nobbe
263142 by: tedd
263143 by: Stut
263146 by: Jay Blanchard
263148 by: Nathan Nobbe
263152 by: Jay Blanchard
Re: Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
263136 by: Per Jessen
Re: Need help adding dBase support to PHP
263137 by: Jon Westcot
263138 by: Nathan Nobbe
263139 by: Jon Westcot
Re: Filter input
263144 by: tedd
Re: How to decode the PHP Source Code
263145 by: tedd
263147 by: David Giragosian
263153 by: Daniel Brown
Re: round()
263149 by: tedd
263150 by: tedd
263151 by: tedd
263154 by: Nathan Nobbe
Re: Something you can do with AJAX + PHP as well
263155 by: tedd
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 ---
[EMAIL PROTECTED] wrote:
I have tried this many way and for some reason
I cannot pull content between the 2 pattern options.
function pullchannel($document)
{
preg_match_all('/<div class="channel" [^<>]*>(.*)<div
class="channel" [^<>]*>/i',$document,$elements);
$match = implode("\r\n",$elements[0]);
$match = str_replace('"',"","$match");
return $match;
}
Give us and example of the input data. And tell us from that example,
what it is you are expecting to extract from it.
Jim
--- End Message ---
--- Begin Message ---
Okay use this as an example I want put parse the html document and toss
everything between the two
Div class channels into an array. The problem I am having is that I cannot
grab everything in between the
Pattern of the preg_match_all.
If I preg_match_all('/<div class="channel" [^<>]*>/i',$document,$elements);
it works perfection
But only arrays the single div statement not everything from div to div. I
think somewhere the syntax of the preg_match_all or the implode that is not
allow this function to work.
Html document
<div class="channel" id="one">
<div class="title">
<b>Station Manager</b>
<div class="topic">Because you Can!
</div>
</div>
</div>
<div class="channel" id="two">
Php script
function pullchannel($document)
{
preg_match_all('/<div class="channel" [^<>]*>(.*)<div class="channel"
[^<>]*>/i',$document,$elements);
$match = implode("\r\n",$elements[0]);
$match = str_replace('"',"","$match");
return $match;
}
-----Original Message-----
From: Jim Lucas [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 11, 2007 9:41 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] preg_match_all Help
[EMAIL PROTECTED] wrote:
> I have tried this many way and for some reason
>
> I cannot pull content between the 2 pattern options.
>
>
>
>
>
> function pullchannel($document)
>
> {
>
> preg_match_all('/<div class="channel" [^<>]*>(.*)<div
> class="channel" [^<>]*>/i',$document,$elements);
>
> $match = implode("\r\n",$elements[0]);
>
> $match = str_replace('"',"","$match");
>
> return $match;
>
> }
>
>
>
>
>
>
Give us and example of the input data. And tell us from that example,
what it is you are expecting to extract from it.
Jim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
...
It would help to see the input text and to know exactly what you're
trying to match.
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---
--- Begin Message ---
Assuming you know all the permissible div tag classes you want to capture the
contents of....
I'd make an array list of them and the use a foreach() loop and capture the
contents you want and not try to capture the contents between the channel divs.
Assemble the output array inside the loop. You can also easily keep track of
which channel ID the contents came from.
What you are attempting directly with preg_match_all() is possible; but, the
required pattern is very messy and will be hard to test to make certain it's
perfect.
[EMAIL PROTECTED] wrote:
Okay use this as an example I want put parse the html document and toss
everything between the two
Div class channels into an array. The problem I am having is that I cannot
grab everything in between the
Pattern of the preg_match_all.
If I preg_match_all('/<div class="channel" [^<>]*>/i',$document,$elements);
it works perfection
But only arrays the single div statement not everything from div to div. I
think somewhere the syntax of the preg_match_all or the implode that is not
allow this function to work.
Html document
<div class="channel" id="one">
<div class="title">
<b>Station Manager</b>
<div class="topic">Because you Can!
</div>
</div>
</div>
<div class="channel" id="two">
Php script
function pullchannel($document)
{
preg_match_all('/<div class="channel" [^<>]*>(.*)<div class="channel"
[^<>]*>/i',$document,$elements);
$match = implode("\r\n",$elements[0]);
$match = str_replace('"',"","$match");
return $match;
}
-----Original Message-----
From: Jim Lucas [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 11, 2007 9:41 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] preg_match_all Help
[EMAIL PROTECTED] wrote:
I have tried this many way and for some reason
I cannot pull content between the 2 pattern options.
function pullchannel($document)
{
preg_match_all('/<div class="channel" [^<>]*>(.*)<div
class="channel" [^<>]*>/i',$document,$elements);
$match = implode("\r\n",$elements[0]);
$match = str_replace('"',"","$match");
return $match;
}
Give us and example of the input data. And tell us from that example,
what it is you are expecting to extract from it.
Jim
--- End Message ---
--- Begin Message ---
I have an educational web site.
I want to create an interface where my students can record their voices
client side and then save messages server side.
I thought Odeo would solve my problems. (The have their own problems
now.) Then I tried: MyChingo and Mobasoft. COme on $6,000 for a site
licence.
Are there any php alternatives? Or do you know an flash code I can find
in sourceforge, that I might hack, or combine PHP & Flash so they can
record me messages in mp3 and submit them?
John
--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
I have an educational web site.
I want to create an interface where my students can record their
voices client side and then save messages server side.
I thought Odeo would solve my problems. (The have their own problems
now.) Then I tried: MyChingo and Mobasoft. COme on $6,000 for a site
licence.
Are there any php alternatives? Or do you know an flash code I can
find in sourceforge, that I might hack, or combine PHP & Flash so they
can record me messages in mp3 and submit them?
John
John-
I guess my question is do you really need Flash for this? If they are
uploading their recorded messages client side then they should be able
to record/convert the audio files to .MP3 before even uploading them. If
you just need the files somewhere online where you can download them for
playback later (or even stream from the site) then really all you need
is an Upload script that will take their audio files and upload them to
the server to a specific location. Now if you want to offer a conversion
of WAV to MP3 for them, I suggest FFMpeg, it's run on the server side.
You can modify your upload script to not only upload the WAV file but
then convert it out to MP3 to a specific location using FFMPeg commands
then trash the WAV file.
Do you have control over the server or are you just hosting your website
there? You'll need to find out if the upload function is even turned on
and what the max file size for upload is. Otherwise you'll just have to
make a few minor adjustments to your php.ini to handle the larger file
uploads.
--- End Message ---
--- Begin Message ---
On Thursday 11 October 2007, Jay Blanchard wrote:
> [snip]
> okay, this is really (!) embarassing, but I have to ask:
>
> Why would I want to use classes in PHP?
>
> I have been using PHP for years now and writing the "normal" functions all
> the time. I have never even bothered working with classes, but now I would
> love to know what makes the classes so special...
>
> Please go easy on me ;o) Just trying to make another step :o)
> [/snip]
>
> Do not be embarrassed, this is a very good question.
>
> First of all what you call "normal" is procedural or functional
> programming. There is nothing wrong with doing things this way and may be
> especially quick and efficient when doing basic web sites and applications.
> Document well and you will have no problem maintaining your code.
One correction. What is being described is procedural or imperative
programming. Functional programming is another beast entirely (closures,
first-class functions, immutable variables, etc.). PHP is not a functional
language by any stretch of the imagination. For functional programming, see
Erlang, Haskel, ML, LISP, and to a lesser extent Javascript.
That's not a knock against PHP, mind you; I'm just pointing out that
functional programming is something different than what you are describing.
It's a common point of confusion because in a procedural language
(traditional PHP, C, etc.) you do everything with functions, so "it's
functional". The difference is that a function is not a base data type,
which is a key component of a functional language.
</semantic nitpick>
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
On 10/12/07, Larry Garfield <[EMAIL PROTECTED]> wrote:
>
> On Thursday 11 October 2007, Jay Blanchard wrote:
> > [snip]
> > okay, this is really (!) embarassing, but I have to ask:
> >
> > Why would I want to use classes in PHP?
> >
> > I have been using PHP for years now and writing the "normal" functions
> all
> > the time. I have never even bothered working with classes, but now I
> would
> > love to know what makes the classes so special...
> >
> > Please go easy on me ;o) Just trying to make another step :o)
> > [/snip]
> >
> > Do not be embarrassed, this is a very good question.
> >
> > First of all what you call "normal" is procedural or functional
> > programming. There is nothing wrong with doing things this way and may
> be
> > especially quick and efficient when doing basic web sites and
> applications.
> > Document well and you will have no problem maintaining your code.
>
> One correction. What is being described is procedural or imperative
> programming. Functional programming is another beast entirely (closures,
> first-class functions, immutable variables, etc.). PHP is not a
> functional
> language by any stretch of the imagination. For functional programming,
> see
> Erlang, Haskel, ML, LISP, and to a lesser extent Javascript.
>
> That's not a knock against PHP, mind you; I'm just pointing out that
> functional programming is something different than what you are
> describing.
> It's a common point of confusion because in a procedural language
> (traditional PHP, C, etc.) you do everything with functions, so "it's
> functional". The difference is that a function is not a base data type,
> which is a key component of a functional language.
an aspect that makes working with javascript rather interesting. i get my
fill of
it there and enjoy php for what it is; and because its more familiar to me
;)
-nathan
--- End Message ---
--- Begin Message ---
At 7:36 AM -0500 10/11/07, Jay Blanchard wrote:
[snip]
okay, this is really (!) embarassing, but I have to ask:
Why would I want to use classes in PHP?
I have been using PHP for years now and writing the "normal" functions all
the time. I have never even bothered working with classes, but now I would
love to know what makes the classes so special...
Please go easy on me ;o) Just trying to make another step :o)
[/snip]
Do not be embarrassed, this is a very good question.
First of all what you call "normal" is procedural or functional
programming. There is nothing wrong with doing things this way and
may be especially quick and efficient when doing basic web sites and
applications. Document well and you will have no problem maintaining
your code.
OOP (object oriented programming) is especially useful when the
application you have created needs to scale. A quick example; you
have sold your products to the consumer market for a long time but
now the commercial market has become interested. Commercial
customers are different than non-commercial customers, different
data, different credit requirements, different shipping, etc. but
they still have a lot in common, If you had a class Customer you
could extended that class to include commercial customers and only
have to code for the unique qualities of that kind of customer. Then
if another type of customer crops up, say a military contract, you
could extend again;
class Customer {
....
}
class CommercialCustomer extends Customer {
/*
*only code unique to commercial customers
* inherits from Customer other variables
* and functions that are common
*/
}
class MilitaryCustomer extends Customer {
/*
*only code unique to military customers
* inherits from Customer other variables
* and functions that are common
*/
}
Jay:
Yes, but I could do that procedurally from within the customer
function by simply adding a customer type (needed regardless) and
using a switch to direct and collect the additional data needed.
function customer($whatWas, $customertype, $whatAdditional)
{
/* do "what was" (i.e., common to all) */
/* then do what's additional unique to type */
switch(1)
{
case $customertype =='Commercial':
commercialCustomer($whatAdditional);
break;
.. and so on
}
function commercialCustomer($whatAdditional)
{
/*
*only code unique to commercial customers
*/
}
function militaryCustomer($whatAdditional)
{
/*
*only code unique to military customers
*/
}
In either case, I still have to write more code to accommodate
scaling. And, if I have more customer types, then it's a simple
matter to add more customer functions and addition case statements to
the initial customer function. I don't see the benefit in using a
class. At this point, it just looks like a different way of doing
things.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
tedd wrote:
function customer($whatWas, $customertype, $whatAdditional)
{
/* do "what was" (i.e., common to all) */
/* then do what's additional unique to type */
switch(1)
{
case $customertype =='Commercial':
commercialCustomer($whatAdditional);
break;
.. and so on
}
function commercialCustomer($whatAdditional)
{
/*
*only code unique to commercial customers
*/
}
function militaryCustomer($whatAdditional)
{
/*
*only code unique to military customers
*/
}
In either case, I still have to write more code to accommodate scaling.
And, if I have more customer types, then it's a simple matter to add
more customer functions and addition case statements to the initial
customer function. I don't see the benefit in using a class. At this
point, it just looks like a different way of doing things.
You can limit the need to add more code like so...
function customer($whatWas, $customertype, $whatAdditional)
{
/* do "what was" (i.e., common to all) */
/* then do what's additional unique to type */
$func = strtolower($customertype).'Customer';
$func($whatAdditional);
}
You could do (and I have done) something similar with classes.
For me the biggest benefit of using OOP is __autoload(). It makes life
so much easier.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
[snip]
Yes, but I could do that procedurally from within the customer
function by simply adding a customer type (needed regardless) and
using a switch to direct and collect the additional data needed.
....
In either case, I still have to write more code to accommodate
scaling. And, if I have more customer types, then it's a simple
matter to add more customer functions and addition case statements to
the initial customer function. I don't see the benefit in using a
class. At this point, it just looks like a different way of doing
things.
[/snip]
No doubt. (are you by chance continuing the other argument, re: interfaces?),
but you have to break open the original tested function, add code to it, test
it, etc. Every time you add a new case you have to break open the existing
function to add that case. After a while, say if you need to drop a customer
type you would have to (not really, you can leave it there and never exercise
the case) break open the original code and delete the un-used code. Any way
that you slice it the original customer function becomes more and more like
spaghetti every day. Documentation for the function has to change each time as
well.
With a class you can inherit all of the base class functionality into a new
customer type. You do not have to break open the base class to add a case, you
just have to create an extension class. Documentation is unique to each class.
--- End Message ---
--- Begin Message ---
On 10/12/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
>
> No doubt. (are you by chance continuing the other argument, re:
> interfaces?), but you have to break open the original tested function, add
> code to it, test it, etc. Every time you add a new case you have to break
> open the existing function to add that case. After a while, say if you need
> to drop a customer type you would have to (not really, you can leave it
> there and never exercise the case) break open the original code and delete
> the un-used code. Any way that you slice it the original customer function
> becomes more and more like spaghetti every day. Documentation for the
> function has to change each time as well.
>
> With a class you can inherit all of the base class functionality into a
> new customer type. You do not have to break open the base class to add a
> case, you just have to create an extension class. Documentation is unique to
> each class.
Stut has demonstrated an example of delegation. when used with objects,
inheritance is not necessary, but it can be used if desired.
use your polymorphic mechanism of choice :)
-nathan
--- End Message ---
--- Begin Message ---
[snip]
> First of all what you call "normal" is procedural or functional
> programming. There is nothing wrong with doing things this way and may
be
> especially quick and efficient when doing basic web sites and
applications.
> Document well and you will have no problem maintaining your code.
One correction. What is being described is procedural or imperative
programming. Functional programming is another beast entirely
(closures,
first-class functions, immutable variables, etc.). PHP is not a
functional
language by any stretch of the imagination. For functional programming,
see
Erlang, Haskel, ML, LISP, and to a lesser extent Javascript.
[/snip]
Thanks for the correction Larry, I knew the difference and just brain
farted.
--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:
> If found a really good quote the other day about XSL but I now can't
> find the link and it's gone from my history but it was something like:
> "You could write a <insert obscure lanaguage here> parser/lexer in
> XSLT but I'm not going to." It's a very powerful language but the
> hardest part most extreme advocates find is knowing when there is a
> better/more practical tool for the job ;)
There's something incredibly elegant about XML+XSLT - which makes it
important to know when NOT to use it ... you're sometimes tempted to
massage your data into XML just to be able to XSLT on it. OTOH, when
your data is hierarchical/recursive in nature, XSLT is brilliant!
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Hi Nathan:
The page you referenced in the PHP documentation is exactly what I saw that
indicated that the dBase functions needed to be compiled in with the
--enable-dbase directive. What I need to know is HOW to do this, even in
general terms. GoDaddy is being very little help (no big surprise there).
Their last message indicated updating values in the php.ini file would let this
work, but, as you pointed out, this isn't an option with the php.ini. I looked
in the phpinfo data and couldn't find anything that matched "dbase" anywhere;
certainly, no section in the output indicated any dBase settings whatsoever.
I'm fearing that I'm going to have to find some other way to handle the
extraction of data from DBF files if I can't get this to work.
Thanks again for your help.
Jon
----- Original Message -----
From: Nathan Nobbe
To: Jon Westcot
Cc: PHP General
Sent: Thursday, October 11, 2007 6:06 PM
Subject: Re: [PHP] Need help adding dBase support to PHP
On 10/11/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
Hi again:
Thanks for the info. From what I can see, GoDaddy does NOT provide
access to ssh. Any other thoughts? Or is there some way to tell me, in
general terms, how to configure PHP to allow the dbase functions to be used?
if godaddy is recommending that you place values in a .htaccess file they
probly mean you should upload a .htaccess
file via ftp. im assuming thats how the give you access to the system (since
there is no ssh access).
im a bit unsure of the .htaccess setting, though i recently posted a small
how-to on using .htaccess files to override
settings in php.ini; this is common in shared hosting environments.
http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess
basically, to have dbase support, php must be compiled w/ --enable-dbase, per
the documentation.
http://www.php.net/manual/en/rlef.dbase.php
perhaps, it is compiled in and the php.ini settings are preventing you from
using the functions (though that sounds hard to believe).
you might try tossing a phpinfo script on the box and looking for dbase in the
output; particularly look for --enable-dbase, or --disable-dbase.
you should see a dbase section also, if its compiled in. if it is there we can
get a better idea of what sort of values could be placed in the
.htaccess file that would influence the behavior of the dbase component on that
system.
-nathan
--- End Message ---
--- Begin Message ---
On 10/12/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
>
> Hi Nathan:
>
> The page you referenced in the PHP documentation is exactly what I saw
> that indicated that the dBase functions needed to be compiled in with the
> --enable-dbase directive. What I need to know is HOW to do this, even in
> general terms.
basically you run about 3 commands.
configure
make
make install
and configure is the command you would pass --enable-dbase to.
windows systems typically have binary installs available; but i really have
never setup php on a windows box.
anyway, the reason i asked about the distribution to begin with is many
distributions handle php configuration / installation so its quite simple.
on gentoo you just add or remove a use flag and emerge it again if you want
to make a change. on debian there are modules so i believe you can just
apt-get a new module if it isnt already installed.
seems nice, but ill tell you, on gentoo you spend time compiling; on debian
you spend time saying where is that package i want and how do i trick
apt-get to install it correctly. but i digress... :)
GoDaddy is being very little help (no big surprise there). Their last
> message indicated updating values in the php.ini file would let this work,
> but, as you pointed out, this isn't an option with the php.ini. I looked
> in the phpinfo data and couldn't find anything that matched "dbase"
> anywhere; certainly, no section in the output indicated any dBase settings
> whatsoever.
if you havent done so i would just use the search feature of your browser
and type in dbase on that page. you should see something in the configure
directive; either --enable-dbase or --disable-dbase most likely.
I'm fearing that I'm going to have to find some other way to handle the
> extraction of data from DBF files if I can't get this to work.
>
are you really committed to godaddy at this point ?
-nathan
--- End Message ---
--- Begin Message ---
Hi Nathan:
Thanks for the info. Unfortunately, it's not my call which host to use.
I'm just being asked to help write some code, and I know that there are DBFs
in the process that need to be examined and brought into MySQL on a daily
basis, if not more often.
From what I've been told, the GoDaddy server is a shared server, which I
guess means that we, the underlings using it, can't really get in and make
whatever changes we'd like to make.
I did use the browser search to look for any occurence of "dbase" in the
phpinfo-returned data, but nothing showed up.
I appreciate the help you've given. I'll just have to wait and see if
the person who owns the site is able to get anywhere with the GoDaddy tech
support.
Thanks again,
Jon
----- Original Message -----
From: "Nathan Nobbe" <[EMAIL PROTECTED]>
To: "Jon Westcot" <[EMAIL PROTECTED]>
Cc: "PHP General" <[EMAIL PROTECTED]>
Sent: Friday, October 12, 2007 12:27 AM
Subject: Re: [PHP] Need help adding dBase support to PHP
> On 10/12/07, Jon Westcot <[EMAIL PROTECTED]> wrote:
> >
> > Hi Nathan:
> >
> > The page you referenced in the PHP documentation is exactly what I
saw
> > that indicated that the dBase functions needed to be compiled in with
the
> > --enable-dbase directive. What I need to know is HOW to do this, even
in
> > general terms.
>
>
> basically you run about 3 commands.
> configure
> make
> make install
> and configure is the command you would pass --enable-dbase to.
> windows systems typically have binary installs available; but i really
have
> never setup php on a windows box.
>
> anyway, the reason i asked about the distribution to begin with is many
> distributions handle php configuration / installation so its quite simple.
> on gentoo you just add or remove a use flag and emerge it again if you
want
> to make a change. on debian there are modules so i believe you can just
> apt-get a new module if it isnt already installed.
> seems nice, but ill tell you, on gentoo you spend time compiling; on
debian
> you spend time saying where is that package i want and how do i trick
> apt-get to install it correctly. but i digress... :)
>
> GoDaddy is being very little help (no big surprise there). Their last
> > message indicated updating values in the php.ini file would let this
work,
> > but, as you pointed out, this isn't an option with the php.ini. I
looked
> > in the phpinfo data and couldn't find anything that matched "dbase"
> > anywhere; certainly, no section in the output indicated any dBase
settings
> > whatsoever.
>
>
> if you havent done so i would just use the search feature of your browser
> and type in dbase on that page. you should see something in the configure
> directive; either --enable-dbase or --disable-dbase most likely.
>
> I'm fearing that I'm going to have to find some other way to handle
the
> > extraction of data from DBF files if I can't get this to work.
> >
>
> are you really committed to godaddy at this point ?
>
> -nathan
>
--- End Message ---
--- Begin Message ---
At 5:17 PM +0200 10/11/07, Manuel Vacelet wrote:
The thing that remains not very clear to me is where validation stop
and where application logic start.
Forgive me if I'm stating the obvious.
For me, there isn't a variable that I receive in any of my scripts
that I don't know what it should be (exact or range) and, as such, I
filter accordingly.
A very good book on this subject is Chris Shiflett's PHP Security
(http://shiflett.org/).
He uses a methodology of clean variables that answers the question you pose.
As for me, the acquiring any variables outside my script requires
checking -- it's a one part process and not two.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 9:57 AM -0400 10/11/07, Daniel Brown wrote:
By the way, Tedd.... you alright there? Ya' kinda' got squashed.
--
Daniel P. Brown
I'm find, but I lost my thought -- it's happening more these days. :-)
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On 10/12/07, tedd <[EMAIL PROTECTED]> wrote:
>
> At 9:57 AM -0400 10/11/07, Daniel Brown wrote:
> >
> >
> > By the way, Tedd.... you alright there? Ya' kinda' got squashed.
> >
> >--
> >Daniel P. Brown
>
> I'm find, but I lost my thought -- it's happening more these days. :-)
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
I found a thought when I was drifting off to sleep last night. Maybe it was
yours, tedd.
But it was in a foreign language - looked like perl. Couldn't make heads or
tails of it.
David
--- End Message ---
--- Begin Message ---
On 10/12/07, David Giragosian <[EMAIL PROTECTED]> wrote:
> On 10/12/07, tedd <[EMAIL PROTECTED]> wrote:
> > At 9:57 AM -0400 10/11/07, Daniel Brown wrote:
> > >
> > >
> > > By the way, Tedd.... you alright there? Ya' kinda' got squashed.
> > >
> > >--
> > >Daniel P. Brown
> >
> > I'm find, but I lost my thought -- it's happening more these days. :-)
> >
> > Cheers,
> >
> > tedd
> > --
> > -------
> > http://sperling.com http://ancientstones.com http://earthstones.com
>
>
> I found a thought when I was drifting off to sleep last night. Maybe it was
> yours, tedd.
> But it was in a foreign language - looked like perl. Couldn't make heads or
> tails of it.
>
> David
>
>
Last night I had a dream of a black and white sitcom about a
couple in the pioneering days of the commercial Internet. It was
called "I Dream of GEnie."
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....
--- End Message ---
--- Begin Message ---
At 10:22 AM -0400 10/11/07, Nathan Nobbe wrote:
On 10/11/07, tedd <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
At 4:18 PM -0600 10/10/07,
<<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
I disagree. I will need to see an example where the round() is inaccurate.
You may disagree if you wish, but the php function round() is
inaccurate by definition -- all *rounding* algorithms are inaccurate.
thats why i suggested the bcmath based algorithm, as bcmath supports arbitrary
precision. i built a quick test script using the method from the
top comment of the
bcmath page, and round(). it allows for quick comparisons of the 2
algorithms and
tells you if the results are the same. i messed around w/ it a
little bit and the results
were the same every time.
Well, if the results were the same, then both exhibit the same
accuracy bias in rounding.
However, precision is not the issue. There's a difference between
precision and accuracy and I am addressing accuracy.
For example, if the answer is 4.5, then 4.4 is more accurate than
4.39999999999, but the later is more precise.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 11:26 AM -0700 10/11/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote:
I get correct results:
5.2.4 PHP_VERSION
round(5.555,2):5.56
toFixed(5.555,2):5.56
You get correct results because the demand you made of the function was simple.
If you expand your demand to thousands of cases, then the bias will emerge.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 7:30 PM -0700 10/11/07, Instruct ICC wrote:
Now I see why BCMath was mentioned.
Yes, but precision is not the issue.
It doesn't make any difference if you are rounding.
(a) 1.489123451985765
or
(b) 148912345198576.5
You still have to make a decision as to if the above (a) rounds to:
(a) 1.48912345198577
or
(a) 1.48912345198576
or the above (b) rounds to:
(b)148912345198577
or
(b) 148912345198576
It's a question of rounding, not precision.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On 10/12/07, tedd <[EMAIL PROTECTED]> wrote:
>
> At 7:30 PM -0700 10/11/07, Instruct ICC wrote:
> >
> >
> >Now I see why BCMath was mentioned.
>
> Yes, but precision is not the issue.
>
> It doesn't make any difference if you are rounding.
>
> (a) 1.489123451985765
>
> or
>
> (b) 148912345198576.5
>
> You still have to make a decision as to if the above (a) rounds to:
>
> (a) 1.48912345198577
>
> or
>
> (a) 1.48912345198576
>
> or the above (b) rounds to:
>
> (b)148912345198577
>
> or
>
> (b) 148912345198576
>
> It's a question of rounding, not precision.
precision is still an issue; after a certain number of digits are used as
the argument; round becomes inaccurate.
from the cases you listed above (a) 1.489123451985765
bcmath results in one of the possible results you listed, (a)
1.48912345198577;
round results in neither possible result.
case (b) 148912345198576.5
bcmath results in one of the possible results, (b)148912345198577;
round results in neither possible result.
this is because the internal binary data type is already filled to capacity
when these calculations are imposed on that
data. im not sure how bcmath handles this internally, but it appears to be
more precise and more accurate. results
will vary based on your hardware, but you can use the second tool i passed
out to find the breaking point on your
system and the first one to test possibilities against the breaking point.
[EMAIL PROTECTED] ~/working/www $ ./bcRound.php 1.489123451985765 14
round result: 1.48912345199
roundbc result: 1.48912345198577
Numerical Comparison: the results are the same
String Comparison: the results are different
[EMAIL PROTECTED] ~/working/www $ ./bcRound.php 148912345198576.5 0
round result: 148912345199000
roundbc result: 148912345198577.
Numerical Comparison: the results are the same
String Comparison: the results are different
i cant seem to get bcmath to choose the alternate rounding path in either
one of the cases.
-nathan
--- End Message ---
--- Begin Message ---
At 5:02 PM +0200 10/11/07, Per Jessen wrote:
tedd wrote:
For example: If you have a process that is taking time server-side and
want to let the user know in real time what the progress is, this is
one way to do it. That's not something (by definition) you can do with
javascript alone, right?
Correct, but it doesn't require any ajax either. That was my main
point.
Yes, but I didn't say that my demo *required* ajax either -- so, I
don't know why you want to make a point about something not claimed?
Here's my demo:
http://webbytedd.com/b/timed-php/
Where does it say that Ajax is required?! The demo is self
explanatory as to what it is showing.
I simply created the demo and presented it here for review. But for
some, instead of understanding what the demo was doing, made
statements that it was an overkill that could be done more simply by
using javascript alone, which was absolutely not true and clearly
demonstrated that they didn't understand the demo (my bad for not
making it more clear).
If you have something constructive to say in relation to the demo,
please do. But, I think it's misleading and confusing to point out
something that was not claimed and then object to it. Why do that?
That's just being argumentative for no reason.
I'll tell you what, why don't you create a demo to exhibit whatever
points you want to make? I am sure that my comments will be more
germane.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---