php-general Digest 18 Feb 2010 22:31:05 -0000 Issue 6597

Topics (messages 302169 through 302182):

PHPDoc (not PhD) question.
        302169 by: Richard Quadling
        302179 by: Nathan Rixham
        302180 by: Nathan Rixham

Linux ERD software
        302170 by: Ashley Sheridan
        302171 by: O. Lavell
        302172 by: Bastien Koert

Dumb Question - Casting
        302173 by: Chuck
        302174 by: Ashley Sheridan
        302175 by: Andrew Ballard
        302176 by: Daniel Egeberg
        302177 by: Joseph Thayne
        302178 by: Nathan Rixham

linux admin needed in israel
        302181 by: Ashley Sheridan

Re: Export/Write rows from DBF to CSV
        302182 by: OBXer

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hello.

Does anyone have any other templates for PHPDoc?

I've found zym's ExtJS PHPDoc template, but this doesn't seem to be
maintained and there are a few bugs (source code not styled, source
code rendered as external windows with broken links, ordered and
unordered lists not rendered with appropriate styling, etc.).

Any suggestsions, fixes, alternatives.

Regards,

Richard.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
> Hello.
> 
> Does anyone have any other templates for PHPDoc?
> 
> I've found zym's ExtJS PHPDoc template, but this doesn't seem to be
> maintained and there are a few bugs (source code not styled, source
> code rendered as external windows with broken links, ordered and
> unordered lists not rendered with appropriate styling, etc.).
> 
> Any suggestsions, fixes, alternatives.
> 
> Regards,
> 
> Richard.
> 

There's a half decent one included with phpUnderControl - never seen one
I *really* like yet though, and never had the time nor inclination to go
making / editing one of the templates.

Regards!

--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
> Hello.
> 
> Does anyone have any other templates for PHPDoc?
> 
> I've found zym's ExtJS PHPDoc template, but this doesn't seem to be
> maintained and there are a few bugs (source code not styled, source
> code rendered as external windows with broken links, ordered and
> unordered lists not rendered with appropriate styling, etc.).
> 
> Any suggestsions, fixes, alternatives.
> 
> Regards,
> 
> Richard.
> 

There's a half decent one included with phpUnderControl - never seen one
I *really* like yet though, and never had the time nor inclination to go
making / editing one of the templates.

Regards!

--- End Message ---
--- Begin Message ---
I don't normally need an ERD, but this latest project I'm on has some
pretty complex database tables, and as I'm working with someone else on
it, I need to plan out exactly how all the tables relate to each other
properly. Do any of you have any suggestions for ERD software that will
run on Linux. It can't be web-based (unless it's something I can run
easily on my own local server) as I won't have access to the Internet
all the time I'm working on this.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Ashley Sheridan wrote:

> I don't normally need an ERD, but this latest project I'm on has some
> pretty complex database tables, and as I'm working with someone else on
> it, I need to plan out exactly how all the tables relate to each other
> properly. Do any of you have any suggestions for ERD software that will
> run on Linux. It can't be web-based (unless it's something I can run
> easily on my own local server) as I won't have access to the Internet
> all the time I'm working on this.

MySQL Workbench, Azzurri Clay.


--- End Message ---
--- Begin Message ---
On Thu, Feb 18, 2010 at 7:26 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> I don't normally need an ERD, but this latest project I'm on has some
> pretty complex database tables, and as I'm working with someone else on
> it, I need to plan out exactly how all the tables relate to each other
> properly. Do any of you have any suggestions for ERD software that will
> run on Linux. It can't be web-based (unless it's something I can run
> easily on my own local server) as I won't have access to the Internet
> all the time I'm working on this.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

Yep, Mysql Workbench is pretty darn good

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
rusty.

Can someone explain why the second expression in this code snippet evaluates
to 7 and not 8?

$a = (int) (0.1 +0.7);

echo "$a\n";

$x = (int) ((0.1 + 0.7) * 10);

echo "$x\n";

$y = (int) (8);

echo "$y\n";

--- End Message ---
--- Begin Message ---
On Thu, 2010-02-18 at 09:47 -0600, Chuck wrote:

> Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
> rusty.
> 
> Can someone explain why the second expression in this code snippet evaluates
> to 7 and not 8?
> 
> $a = (int) (0.1 +0.7);
> 
> echo "$a\n";
> 
> $x = (int) ((0.1 + 0.7) * 10);
> 
> echo "$x\n";
> 
> $y = (int) (8);
> 
> echo "$y\n";


It works as expected if you take out the int() parts in each line. I'm
not sure why, but the use of int() seems to be screwing around with the
results. That's why the first line outputs a 0.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Thu, Feb 18, 2010 at 10:50 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Thu, 2010-02-18 at 09:47 -0600, Chuck wrote:
>
>> Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
>> rusty.
>>
>> Can someone explain why the second expression in this code snippet evaluates
>> to 7 and not 8?
>>
>> $a = (int) (0.1 +0.7);
>>
>> echo "$a\n";
>>
>> $x = (int) ((0.1 + 0.7) * 10);
>>
>> echo "$x\n";
>>
>> $y = (int) (8);
>>
>> echo "$y\n";
>
>
> It works as expected if you take out the int() parts in each line. I'm
> not sure why, but the use of int() seems to be screwing around with the
> results. That's why the first line outputs a 0.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

Another fine example of floating point math.

<?php

$x = ((0.1 + 0.7) * 10);

echo "((0.1 + 0.7) * 10) === $x\n";
// ((0.1 + 0.7) * 10) === 8


var_dump(8 == $x);
// bool(false)

var_dump($x - (int) $x);
// float(1)

var_dump(8 - $x);
// float(8.8817841970013E-16)

?>

Andrew

--- End Message ---
--- Begin Message ---
On Thu, Feb 18, 2010 at 16:47, Chuck <chuck.car...@gmail.com> wrote:
> Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
> rusty.
>
> Can someone explain why the second expression in this code snippet evaluates
> to 7 and not 8?
>
> $a = (int) (0.1 +0.7);
>
> echo "$a\n";
>
> $x = (int) ((0.1 + 0.7) * 10);
>
> echo "$x\n";
>
> $y = (int) (8);
>
> echo "$y\n";
>

The reason why you get 7 instead of 8 is because you are using
floating point arithmetic. 0.1 (i.e. the fraction 1/10) does not have
a finite representation in base 2 (like you cannot finitely represent
1/3 in base 10). So the number 0.1 is represented in the computer as a
number that is strictly less than 0.1 so when you do 0.1+0.7=x then
you have x<0.8 in the computer (think 7.9999999...). When you cast to
int you just truncate the number, i.e. you chop off the fractional
part leaving you with 7.

-- 
Daniel Egeberg

--- End Message ---
--- Begin Message --- According to the PHP manual using the same expression, "Never cast an unknown fraction to integer, as this can sometimes lead to unexpected results". My guess is that since it is an expression of floating points, that the result is not quite 8 (for whatever reason). Therefore, it is rounded towards 0. Of course, that is only a guess, and I have no true documentation on it.

Ashley Sheridan wrote:
On Thu, 2010-02-18 at 09:47 -0600, Chuck wrote:

Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
rusty.

Can someone explain why the second expression in this code snippet evaluates
to 7 and not 8?

$a = (int) (0.1 +0.7);

echo "$a\n";

$x = (int) ((0.1 + 0.7) * 10);

echo "$x\n";

$y = (int) (8);

echo "$y\n";


It works as expected if you take out the int() parts in each line. I'm
not sure why, but the use of int() seems to be screwing around with the
results. That's why the first line outputs a 0.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
Daniel Egeberg wrote:
> On Thu, Feb 18, 2010 at 16:47, Chuck <chuck.car...@gmail.com> wrote:
>> Sorry, been doing heavy perl and haven't written any PHP in 3 years so a tad
>> rusty.
>>
>> Can someone explain why the second expression in this code snippet evaluates
>> to 7 and not 8?
>>
>> $a = (int) (0.1 +0.7);
>>
>> echo "$a\n";
>>
>> $x = (int) ((0.1 + 0.7) * 10);
>>
>> echo "$x\n";
>>
>> $y = (int) (8);
>>
>> echo "$y\n";
>>
> 
> The reason why you get 7 instead of 8 is because you are using
> floating point arithmetic. 0.1 (i.e. the fraction 1/10) does not have
> a finite representation in base 2 (like you cannot finitely represent
> 1/3 in base 10). So the number 0.1 is represented in the computer as a
> number that is strictly less than 0.1 so when you do 0.1+0.7=x then
> you have x<0.8 in the computer (think 7.9999999...). When you cast to
> int you just truncate the number, i.e. you chop off the fractional
> part leaving you with 7.
> 

yup as Daniel pointed out; this is correct - love floats & casting!

see:

$y = ((0.1 + 0.7) * 10);
$x = (int)$y;
$z = intval($y);
var_dump($y);
var_dump(serialize($y));
var_dump($x);
var_dump($z);

outputs:
float(8)
string(55) "d:7.99999999999999911182158029987476766109466552734375;"
int(7)
int(7)

lovely! - note: serializing gives us the exact value of the float

regards,

Nathan



--- End Message ---
--- Begin Message ---
I know it' not the right place to post this, but this is the only
mailing list i'm on, and guessed this might be interesting to one of you
possibly?

I've a friend looking to place a Linux administrator in Israel (I've no
idea what part, she didn't say)

If you want, you can replay back off-list and I can pass her work email
address along or something. I'm just asking here as a favor for her
really.

Sorry if this message doesn't seem appropriate. I won't be making a
habit of this sort of thing, honest! Like I said, just doing a friend a
favor, and not getting anything out of this myself

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
I'm trying to adopt this piece of code for my use.  I fixed the csv_data .=
trim error.  Does anyone know how I can fix empty fields?  Everything is
dumping to a csv file but information is not matching up.  I don't know if I
can insert a space or something if field is blank?


Rahul S. Johari-2 wrote:
> 
> Ave,
> 
> I'm trying to retrieve data from a DBF database and write it to a CSV  
> file in a comma delimited format. I'm able to get the data and write  
> it to CSV, but it only writes the last row/record ... not all the  
> records. I know I don't have the correct code and I'm hoping someone  
> can help me...
> 
> _____________
> #CREATE CSV
> $date = date('mdy');
> $_file = 'CSV/TransferData_'.$date.'.csv';
> $_fp = @fopen( $_file, 'w' );
> 
>       #SELECT DBF TO OPEN - READ ONLY
>       $db = dbase_open("mydata.dbf", 0);
>       #PULL UP RECORD
>       if ($db) {
>         $record_numbers = dbase_numrecords($db);
>         for ($i = 1; $i <= $record_numbers; $i++) {
>               $row = dbase_get_record_with_names($db, $i);
>               
>               #WRITE ROWS TO VARIABLE
>               $_csv_data = 
> trim($row['PHONE']).",".trim($row['DATE']).","."\n";  
> <-- THIS is where my problem is! This only writes the last row!!
>         }
>       }
> 
> #WRITE TO CSV 
> @fwrite( $_fp, $_csv_data );
> @fclose( $_fp );
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Export-Write-rows-from-DBF-to-CSV-tp22496924p27646825.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---

Reply via email to