php-general Digest 6 Apr 2008 01:54:50 -0000 Issue 5388

Topics (messages 272566 through 272576):

Re: everything as classes
        272566 by: Larry Garfield

Re: PostTrack Updates
        272567 by: Casey
        272568 by: Robert Cummings
        272569 by: Robert Cummings
        272570 by: Daniel Brown
        272574 by: Nathan Nobbe
        272576 by: Daniel Brown

Re: How to jump to line number in large file
        272571 by: Steve McGill
        272572 by: Robert Cummings
        272573 by: Steve McGill
        272575 by: Jim Lucas

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 Thursday 03 April 2008, robert wrote:
> Along the lines of a previous post "How to get a code review", I am
> curious if it is overkill to create everything in classes. For
> example, a movie website where there is a class for the movie
> datatype, class for getting/adding/deleting/updating movie's data to
> the database, and class for displaying the data. (Of course there are
> classes for  general functionality like sql database connection etc.)
> For listing movies alone there are at least 4 different inheritance
> classes for chronological, alphabetic, category and keyword. Anyway
> this is how I coded something similar but for Flash/Actionscript site
> but I'm not sure about a PHP site. I appreciate your comments.
> - robert

Procedural code is a hack saw.

OOP is a table saw.

Sometimes, all you need is a hack saw.  It's simple, straightforward, easy to 
learn how to use, and you can pick it up and use it in various ways and 
places.  It's harder to get wrong, and when you do you can usually just turn 
your hand at a weird angle for a bit and make it work.

Other times, you really need a table saw.  It takes longer to build and setup 
and can be more difficult to understand if you're not used to it, but if done 
properly will slice and dice wood in ways you couldn't even think of with a 
hack saw.  Of course, if you build it wrong then you're now out a very 
expensive table.

Use whichever makes sense for your use case.  In a language like PHP that has 
strong support for both, both the "everything is an object" and "never use 
objects" viewpoints are, well, ignorant. :-)

-- 
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 Apr 5, 2008, at 6:23 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:


On Apr 5, 2008, at 1:48 AM, Robert Cummings wrote:


On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote:
Robert Cummings wrote:
<?php echo "On Fri, 2008-04-04 at 17:23 -0400, Daniel Brown wrote: \n" ?> <?php echo "> Some changes take effect with the PostTrack metrics \n" ?> <?php echo "> system with this week (will show up in next week's \n" ?>
<?php echo "> report). There's one bug fix and a new feature added,
\n" ?>
<?php echo "> in which some of you may be really interested.\n" ?>
<?php echo ">\n" ?>
<?php echo ">     CHANGELOG\n" ?>
<?php echo "\n" ?>
<?php echo "> Fixed a bug that would (seemingly random) \n" ?> <?php echo "> split a user's post recording over multiple entries. \n" ?> <?php echo "> (See this week's report: Zoltan Nemeth for example) \n" ?> <?php echo "> Added a new CodeCount feature. Explained \n" ?>
<?php echo ">         below.\n" ?>
<?php echo ">\n" ?>
<?php echo "> The CodeCount feature will, from now on, track \n" ?> <?php echo "> the amount of [pseudo]code everyone posts to the \n" ?> <?php echo "> list. However, for a variety of reasons (including \n" ?> <?php echo "> enforcing Good Coding Practices[tm], there will be \n" ?>
<?php echo "> some rules:\n" ?>
<?php echo ">\n" ?>
<?php echo "> * short_open_tags code will not be counted. \n" ?>
<?php echo ">           It must begin with <?php, not <?, and\n" ?>
<?php echo ">           <?=\$variable;?> things won't count.\n" ?>
<?php echo ">         * All code must be properly closed as well as
\n" ?>
<?php echo ">           opened. Thus, <?php must be followed
by ?>.\n" ?>
<?php echo "> * You can include multiple blocks of code, \n" ?>
<?php echo ">           and all will be tallied. So:\n" ?>
<?php echo ">             <?php\n" ?>
<?php echo ">                 // Block one\n" ?>
<?php echo ">             ?>\n" ?>
<?php echo ">             .... and ....\n" ?>
<?php echo ">             <?php\n" ?>
<?php echo ">                 // Block two\n" ?>
<?php echo ">             ?>\n" ?>
<?php echo ">             .... will both be counted.\n" ?>
<?php echo ">\n" ?>
<?php echo ">     Some notes that should be obvious:\n" ?>
<?php echo ">         * HTML won't be counted unless included in an
\n" ?>
<?php echo "> echo/print construct or a HEREDOC/NOWDOC \n" ?> <?php echo "> (when used). Only the code between the \n" ?>
<?php echo ">           <?php and ?> tags will be counted.\n" ?>
<?php echo ">         * The CodeCount procedure *does* count\n" ?>
<?php echo "> comments as code. This can be changed if \n" ?>
<?php echo ">           there's enough desire.\n" ?>
<?php echo "> * CodeCount *will not* differentiate between \n" ?> <?php echo "> \"Good\" and \"Bad\" code. If you forget a \n" ?>
<?php echo ">           semicolon, it'll still count.\n" ?>
<?php echo ">\n" ?>
<?php echo "> --\n" ?>
<?php echo "> </Daniel P. Brown>\n" ?>
<?php echo "> Ask me about:\n" ?>
<?php echo "> Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
<?php echo "> starting @ \$19.99/mo., and shared hosting starting @
\n" ?>
<?php echo "> \$2.50/mo. Unmanaged, managed, and fully-managed! \n" ?>

I don't know about anyone else, but I am absolutely stoked about this
development!

Cheers,
Rob.

wait you forgot the semi-colon...  ah, that's right, he said grammar
mistakes were not counted...

Perfectly valid to omit the last semi-colon when closing a PHP block.

<?PHP echo 'So does the new code count all quoted code as well? :)';?>
<?PHP echo 'If so... Then we are going to have a ton of code to start with!';?>




:)

;)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP


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




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

Does it count if I quote it! :)

--- End Message ---
--- Begin Message ---
On Sat, 2008-04-05 at 09:23 -0400, Jason Pruim wrote:
> On Apr 5, 2008, at 1:48 AM, Robert Cummings wrote:
> 
> >
> > On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote:
> >> Robert Cummings wrote:
> >>> <?php echo "On Fri, 2008-04-04 at 17:23 -0400, Daniel Brown wrote: 
> >>> \n" ?>
> >>> <?php echo "> Some changes take effect with the PostTrack metrics 
> >>> \n" ?>
> >>> <?php echo "> system with this week (will show up in next week's 
> >>> \n" ?>
> >>> <?php echo "> report). There's one bug fix and a new feature added,
> >>> \n" ?>
> >>> <?php echo "> in which some of you may be really interested.\n" ?>
> >>> <?php echo ">\n" ?>
> >>> <?php echo ">     CHANGELOG\n" ?>
> >>> <?php echo "\n" ?>
> >>> <?php echo ">         Fixed a bug that would (seemingly random) 
> >>> \n" ?>
> >>> <?php echo "> split a user's post recording over multiple entries. 
> >>> \n" ?>
> >>> <?php echo "> (See this week's report: Zoltan Nemeth for example) 
> >>> \n" ?>
> >>> <?php echo ">         Added a new CodeCount feature.  Explained 
> >>> \n" ?>
> >>> <?php echo ">         below.\n" ?>
> >>> <?php echo ">\n" ?>
> >>> <?php echo ">     The CodeCount feature will, from now on, track 
> >>> \n" ?>
> >>> <?php echo "> the amount of [pseudo]code everyone posts to the\n" ?>
> >>> <?php echo "> list. However, for a variety of reasons (including 
> >>> \n" ?>
> >>> <?php echo "> enforcing Good Coding Practices[tm], there will be 
> >>> \n" ?>
> >>> <?php echo "> some rules:\n" ?>
> >>> <?php echo ">\n" ?>
> >>> <?php echo ">         * short_open_tags code will not be counted. 
> >>> \n" ?>
> >>> <?php echo ">           It must begin with <?php, not <?, and\n" ?>
> >>> <?php echo ">           <?=\$variable;?> things won't count.\n" ?>
> >>> <?php echo ">         * All code must be properly closed as well as
> >>> \n" ?>
> >>> <?php echo ">           opened. Thus, <?php must be followed
> >>> by ?>.\n" ?>
> >>> <?php echo ">         * You can include multiple blocks of code, 
> >>> \n" ?>
> >>> <?php echo ">           and all will be tallied. So:\n" ?>
> >>> <?php echo ">             <?php\n" ?>
> >>> <?php echo ">                 // Block one\n" ?>
> >>> <?php echo ">             ?>\n" ?>
> >>> <?php echo ">             .... and ....\n" ?>
> >>> <?php echo ">             <?php\n" ?>
> >>> <?php echo ">                 // Block two\n" ?>
> >>> <?php echo ">             ?>\n" ?>
> >>> <?php echo ">             .... will both be counted.\n" ?>
> >>> <?php echo ">\n" ?>
> >>> <?php echo ">     Some notes that should be obvious:\n" ?>
> >>> <?php echo ">         * HTML won't be counted unless included in an
> >>> \n" ?>
> >>> <?php echo ">           echo/print construct or a HEREDOC/NOWDOC 
> >>> \n" ?>
> >>> <?php echo ">           (when used). Only the code between the\n" ?>
> >>> <?php echo ">           <?php and ?> tags will be counted.\n" ?>
> >>> <?php echo ">         * The CodeCount procedure *does* count\n" ?>
> >>> <?php echo ">           comments as code. This can be changed if 
> >>> \n" ?>
> >>> <?php echo ">           there's enough desire.\n" ?>
> >>> <?php echo ">         * CodeCount *will not* differentiate between 
> >>> \n" ?>
> >>> <?php echo ">           \"Good\" and \"Bad\" code. If you forget a 
> >>> \n" ?>
> >>> <?php echo ">           semicolon, it'll still count.\n" ?>
> >>> <?php echo ">\n" ?>
> >>> <?php echo "> --\n" ?>
> >>> <?php echo "> </Daniel P. Brown>\n" ?>
> >>> <?php echo "> Ask me about:\n" ?>
> >>> <?php echo "> Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
> >>> <?php echo "> starting @ \$19.99/mo., and shared hosting starting @
> >>> \n" ?>
> >>> <?php echo "> \$2.50/mo. Unmanaged, managed, and fully-managed! 
> >>> \n" ?>
> >>>
> >>> I don't know about anyone else, but I am absolutely stoked about  
> >>> this
> >>> development!
> >>>
> >>> Cheers,
> >>> Rob.
> >>
> >> wait you forgot the semi-colon...  ah, that's right, he said grammar
> >> mistakes were not counted...
> >
> > Perfectly valid to omit the last semi-colon when closing a PHP block.
> 
> <?PHP echo 'So does the new code count all quoted code as well? :)';?>
> <?PHP echo 'If so... Then we are going to have a ton of code to start  
> with!';?>

I don't know, but that's a very good question.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Sat, 2008-04-05 at 07:21 -0700, Casey wrote:
> On Apr 5, 2008, at 6:23 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> 
> >
> > On Apr 5, 2008, at 1:48 AM, Robert Cummings wrote:
> >
> >>
> >> On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote:
> >>> Robert Cummings wrote:
> >>>> <?php echo "On Fri, 2008-04-04 at 17:23 -0400, Daniel Brown wrote: 
> >>>> \n" ?>
> >>>> <?php echo "> Some changes take effect with the PostTrack metrics 
> >>>> \n" ?>
> >>>> <?php echo "> system with this week (will show up in next week's 
> >>>> \n" ?>
> >>>> <?php echo "> report). There's one bug fix and a new feature added,
> >>>> \n" ?>
> >>>> <?php echo "> in which some of you may be really interested.\n" ?>
> >>>> <?php echo ">\n" ?>
> >>>> <?php echo ">     CHANGELOG\n" ?>
> >>>> <?php echo "\n" ?>
> >>>> <?php echo ">         Fixed a bug that would (seemingly random) 
> >>>> \n" ?>
> >>>> <?php echo "> split a user's post recording over multiple entries. 
> >>>> \n" ?>
> >>>> <?php echo "> (See this week's report: Zoltan Nemeth for example) 
> >>>> \n" ?>
> >>>> <?php echo ">         Added a new CodeCount feature.  Explained 
> >>>> \n" ?>
> >>>> <?php echo ">         below.\n" ?>
> >>>> <?php echo ">\n" ?>
> >>>> <?php echo ">     The CodeCount feature will, from now on, track 
> >>>> \n" ?>
> >>>> <?php echo "> the amount of [pseudo]code everyone posts to the 
> >>>> \n" ?>
> >>>> <?php echo "> list. However, for a variety of reasons (including 
> >>>> \n" ?>
> >>>> <?php echo "> enforcing Good Coding Practices[tm], there will be 
> >>>> \n" ?>
> >>>> <?php echo "> some rules:\n" ?>
> >>>> <?php echo ">\n" ?>
> >>>> <?php echo ">         * short_open_tags code will not be counted. 
> >>>> \n" ?>
> >>>> <?php echo ">           It must begin with <?php, not <?, and\n" ?>
> >>>> <?php echo ">           <?=\$variable;?> things won't count.\n" ?>
> >>>> <?php echo ">         * All code must be properly closed as well as
> >>>> \n" ?>
> >>>> <?php echo ">           opened. Thus, <?php must be followed
> >>>> by ?>.\n" ?>
> >>>> <?php echo ">         * You can include multiple blocks of code, 
> >>>> \n" ?>
> >>>> <?php echo ">           and all will be tallied. So:\n" ?>
> >>>> <?php echo ">             <?php\n" ?>
> >>>> <?php echo ">                 // Block one\n" ?>
> >>>> <?php echo ">             ?>\n" ?>
> >>>> <?php echo ">             .... and ....\n" ?>
> >>>> <?php echo ">             <?php\n" ?>
> >>>> <?php echo ">                 // Block two\n" ?>
> >>>> <?php echo ">             ?>\n" ?>
> >>>> <?php echo ">             .... will both be counted.\n" ?>
> >>>> <?php echo ">\n" ?>
> >>>> <?php echo ">     Some notes that should be obvious:\n" ?>
> >>>> <?php echo ">         * HTML won't be counted unless included in an
> >>>> \n" ?>
> >>>> <?php echo ">           echo/print construct or a HEREDOC/NOWDOC 
> >>>> \n" ?>
> >>>> <?php echo ">           (when used). Only the code between the 
> >>>> \n" ?>
> >>>> <?php echo ">           <?php and ?> tags will be counted.\n" ?>
> >>>> <?php echo ">         * The CodeCount procedure *does* count\n" ?>
> >>>> <?php echo ">           comments as code. This can be changed if 
> >>>> \n" ?>
> >>>> <?php echo ">           there's enough desire.\n" ?>
> >>>> <?php echo ">         * CodeCount *will not* differentiate between 
> >>>> \n" ?>
> >>>> <?php echo ">           \"Good\" and \"Bad\" code. If you forget a 
> >>>> \n" ?>
> >>>> <?php echo ">           semicolon, it'll still count.\n" ?>
> >>>> <?php echo ">\n" ?>
> >>>> <?php echo "> --\n" ?>
> >>>> <?php echo "> </Daniel P. Brown>\n" ?>
> >>>> <?php echo "> Ask me about:\n" ?>
> >>>> <?php echo "> Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
> >>>> <?php echo "> starting @ \$19.99/mo., and shared hosting starting @
> >>>> \n" ?>
> >>>> <?php echo "> \$2.50/mo. Unmanaged, managed, and fully-managed! 
> >>>> \n" ?>
> >>>>
> >>>> I don't know about anyone else, but I am absolutely stoked about  
> >>>> this
> >>>> development!
> >>>>
> >>>> Cheers,
> >>>> Rob.
> >>>
> >>> wait you forgot the semi-colon...  ah, that's right, he said grammar
> >>> mistakes were not counted...
> >>
> >> Perfectly valid to omit the last semi-colon when closing a PHP block.
> >
> > <?PHP echo 'So does the new code count all quoted code as well? :)';?>
> > <?PHP echo 'If so... Then we are going to have a ton of code to  
> > start with!';?>
>
> Does it count if I quote it! :)

You mean a quote of a quote of a quote? Didn't anyone teach you to trim
my posts?  ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
    Top-posting because I don't care.

    I knew it would cause a lot of this up front, but eventually it
could be potentially useful, once the monkeys realize that throwing
poop isn't as much fun as it looked like on television.  ;-P

    By the way, if you guys have ideas for improvement, feel free to
modify the code.  I have to repackage it with the new version, but
I'll put it up soon.

    This concludes our top-posting day.  Happy Saturday, all.


On Sat, Apr 5, 2008 at 10:30 AM, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
>
>  On Sat, 2008-04-05 at 07:21 -0700, Casey wrote:
>  > On Apr 5, 2008, at 6:23 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
>  >
>  > >
>  > > On Apr 5, 2008, at 1:48 AM, Robert Cummings wrote:
>  > >
>  > >>
>  > >> On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote:
>  > >>> Robert Cummings wrote:
>  > >>>> <?php echo "On Fri, 2008-04-04 at 17:23 -0400, Daniel Brown wrote:
>  > >>>> \n" ?>
>  > >>>> <?php echo "> Some changes take effect with the PostTrack metrics
>  > >>>> \n" ?>
>  > >>>> <?php echo "> system with this week (will show up in next week's
>  > >>>> \n" ?>
>  > >>>> <?php echo "> report). There's one bug fix and a new feature added,
>  > >>>> \n" ?>
>  > >>>> <?php echo "> in which some of you may be really interested.\n" ?>
>  > >>>> <?php echo ">\n" ?>
>  > >>>> <?php echo ">     CHANGELOG\n" ?>
>  > >>>> <?php echo "\n" ?>
>  > >>>> <?php echo ">         Fixed a bug that would (seemingly random)
>  > >>>> \n" ?>
>  > >>>> <?php echo "> split a user's post recording over multiple entries.
>  > >>>> \n" ?>
>  > >>>> <?php echo "> (See this week's report: Zoltan Nemeth for example)
>  > >>>> \n" ?>
>  > >>>> <?php echo ">         Added a new CodeCount feature.  Explained
>  > >>>> \n" ?>
>  > >>>> <?php echo ">         below.\n" ?>
>  > >>>> <?php echo ">\n" ?>
>  > >>>> <?php echo ">     The CodeCount feature will, from now on, track
>  > >>>> \n" ?>
>  > >>>> <?php echo "> the amount of [pseudo]code everyone posts to the
>  > >>>> \n" ?>
>  > >>>> <?php echo "> list. However, for a variety of reasons (including
>  > >>>> \n" ?>
>  > >>>> <?php echo "> enforcing Good Coding Practices[tm], there will be
>  > >>>> \n" ?>
>  > >>>> <?php echo "> some rules:\n" ?>
>  > >>>> <?php echo ">\n" ?>
>  > >>>> <?php echo ">         * short_open_tags code will not be counted.
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           It must begin with <?php, not <?, and\n" ?>
>  > >>>> <?php echo ">           <?=\$variable;?> things won't count.\n" ?>
>  > >>>> <?php echo ">         * All code must be properly closed as well as
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           opened. Thus, <?php must be followed
>  > >>>> by ?>.\n" ?>
>  > >>>> <?php echo ">         * You can include multiple blocks of code,
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           and all will be tallied. So:\n" ?>
>  > >>>> <?php echo ">             <?php\n" ?>
>  > >>>> <?php echo ">                 // Block one\n" ?>
>  > >>>> <?php echo ">             ?>\n" ?>
>  > >>>> <?php echo ">             .... and ....\n" ?>
>  > >>>> <?php echo ">             <?php\n" ?>
>  > >>>> <?php echo ">                 // Block two\n" ?>
>  > >>>> <?php echo ">             ?>\n" ?>
>  > >>>> <?php echo ">             .... will both be counted.\n" ?>
>  > >>>> <?php echo ">\n" ?>
>  > >>>> <?php echo ">     Some notes that should be obvious:\n" ?>
>  > >>>> <?php echo ">         * HTML won't be counted unless included in an
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           echo/print construct or a HEREDOC/NOWDOC
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           (when used). Only the code between the
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           <?php and ?> tags will be counted.\n" ?>
>  > >>>> <?php echo ">         * The CodeCount procedure *does* count\n" ?>
>  > >>>> <?php echo ">           comments as code. This can be changed if
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           there's enough desire.\n" ?>
>  > >>>> <?php echo ">         * CodeCount *will not* differentiate between
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           \"Good\" and \"Bad\" code. If you forget a
>  > >>>> \n" ?>
>  > >>>> <?php echo ">           semicolon, it'll still count.\n" ?>
>  > >>>> <?php echo ">\n" ?>
>  > >>>> <?php echo "> --\n" ?>
>  > >>>> <?php echo "> </Daniel P. Brown>\n" ?>
>  > >>>> <?php echo "> Ask me about:\n" ?>
>  > >>>> <?php echo "> Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
>  > >>>> <?php echo "> starting @ \$19.99/mo., and shared hosting starting @
>  > >>>> \n" ?>
>  > >>>> <?php echo "> \$2.50/mo. Unmanaged, managed, and fully-managed!
>  > >>>> \n" ?>
>  > >>>>
>  > >>>> I don't know about anyone else, but I am absolutely stoked about
>  > >>>> this
>  > >>>> development!
>  > >>>>
>  > >>>> Cheers,
>  > >>>> Rob.
>  > >>>
>  > >>> wait you forgot the semi-colon...  ah, that's right, he said grammar
>  > >>> mistakes were not counted...
>  > >>
>  > >> Perfectly valid to omit the last semi-colon when closing a PHP block.
>  > >
>  > > <?PHP echo 'So does the new code count all quoted code as well? :)';?>
>  > > <?PHP echo 'If so... Then we are going to have a ton of code to
>  > > start with!';?>
>  >
>
> > Does it count if I quote it! :)
>
>  You mean a quote of a quote of a quote? Didn't anyone teach you to trim
>  my posts?  ;)
>
>
>
>  Cheers,
>  Rob.
>  --
>  http://www.interjinn.com
>  Application and Templating Framework for PHP
>
>



-- 
</Daniel P. Brown>
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

--- End Message ---
--- Begin Message ---
On Sat, Apr 5, 2008 at 12:51 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:

>    Top-posting because I don't care.
>
>    I knew it would cause a lot of this up front, but eventually it
> could be potentially useful, once the monkeys realize that throwing
> poop isn't as much fun as it looked like on television.  ;-P
>
>    By the way, if you guys have ideas for improvement, feel free to
> modify the code.  I have to repackage it with the new version, but
> I'll put it up soon.

<?php
${"well dan, im not a fan of the restriction of html only being tallied if
embedded in strings.  one of the primary features of php is the 'templating'
aspect"}
= 'eg.';
?>

<?php
$phpIsCool = 'yes we know';
?>
<p>$phpIsCool</p>
<?php
$shouldPhpTemplatingBeCounted = 'i think so';
?>
<p>$shouldPhpTemplatingBeCounted</p>

<?php
${"The next cool feature we need to think about is a rant counter ;)"}

='nathan';
?>

--- End Message ---
--- Begin Message ---
<?php
$enough = 'enough';
?>

On Sat, Apr 5, 2008 at 7:10 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Sat, Apr 5, 2008 at 12:51 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> >    Top-posting because I don't care.
> >
> >    I knew it would cause a lot of this up front, but eventually it
> > could be potentially useful, once the monkeys realize that throwing
> > poop isn't as much fun as it looked like on television.  ;-P
> >
> >    By the way, if you guys have ideas for improvement, feel free to
> > modify the code.  I have to repackage it with the new version, but
> > I'll put it up soon.
> <?php
> ${"well dan, im not a fan of the restriction of html only being tallied if
> embedded in strings.  one of the primary features of php is the 'templating'
> aspect"}
>  = 'eg.';
> ?>
>
> <?php
> $phpIsCool = 'yes we know';
> ?>
> <p>$phpIsCool</p>
> <?php
> $shouldPhpTemplatingBeCounted = 'i think so';
> ?>
> <p>$shouldPhpTemplatingBeCounted</p>
>
> <?php
> ${"The next cool feature we need to think about is a rant counter ;)"}
>
> ='nathan';
> ?>
>
>



-- 
</Daniel P. Brown>
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

--- End Message ---
--- Begin Message ---
"Richard Heyes" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> Thanks for the heads up on fgetc() incrementing by one. I hadn't actually 
>> tested that code yet, I was using the original fseek($handle,$pos).
>>
>> strpos would be ideal but it needs to work on a string and not a file - I 
>> don't want to load a 100Mb file into memory if I don't have to. Perhaps I 
>> should test how quick the fgets() and ftell() method is because at least 
>> it loads in one line at a time.
>>
>> Does anybody know any other ways to go about the problem?
>
> Haven't read the rest of the thread, and so going by the subject alone, 
> fgets() finishes when it encounters a newline, so you can use this 
> wondrous fact to seek to a specific line:
>
> <?php
>     $fp  = fopen('filename', 'r');
>     $num = 18; // Desired line number
>
>     for ($i=0; $i<$num; $i++)
>         $line = fgets($fp);
>
>     echo $line;
> ?>
>
> It works because fgets() stops when it encounters a newline (\n). So it's 
> just a case of counting the calls to fgets().

fgets() would work but as I'm constantly jumping around a 500,000 line file 
I thought it was better to maintain a cache of line number positions.

As a final update to anybody following:

- Taking away the unnecessary fseek() made the script execute in 63 seconds
- Using a buffer system, (reading in 1Mb of the text file at a time and then 
looping through the string in memory) made the script execute in 36 seconds. 
Huge improvement, but...
- Porting the code to C++, doing a shell_exec and reading the results back 
in to PHP, took less than 2 seconds.

As fgetc() etc are all effectively C wrappers I was quite surprised at the 
speed increase....

Best wishes,
Steve



--- End Message ---
--- Begin Message ---
On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote:
> "Richard Heyes" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> >> Thanks for the heads up on fgetc() incrementing by one. I hadn't actually 
> >> tested that code yet, I was using the original fseek($handle,$pos).
> >>
> >> strpos would be ideal but it needs to work on a string and not a file - I 
> >> don't want to load a 100Mb file into memory if I don't have to. Perhaps I 
> >> should test how quick the fgets() and ftell() method is because at least 
> >> it loads in one line at a time.
> >>
> >> Does anybody know any other ways to go about the problem?
> >
> > Haven't read the rest of the thread, and so going by the subject alone, 
> > fgets() finishes when it encounters a newline, so you can use this 
> > wondrous fact to seek to a specific line:
> >
> > <?php
> >     $fp  = fopen('filename', 'r');
> >     $num = 18; // Desired line number
> >
> >     for ($i=0; $i<$num; $i++)
> >         $line = fgets($fp);
> >
> >     echo $line;
> > ?>
> >
> > It works because fgets() stops when it encounters a newline (\n). So it's 
> > just a case of counting the calls to fgets().
> 
> fgets() would work but as I'm constantly jumping around a 500,000 line file 
> I thought it was better to maintain a cache of line number positions.
> 
> As a final update to anybody following:
> 
> - Taking away the unnecessary fseek() made the script execute in 63 seconds
> - Using a buffer system, (reading in 1Mb of the text file at a time and then 
> looping through the string in memory) made the script execute in 36 seconds. 
> Huge improvement, but...
> - Porting the code to C++, doing a shell_exec and reading the results back 
> in to PHP, took less than 2 seconds.
> 
> As fgetc() etc are all effectively C wrappers I was quite surprised at the 
> speed increase....

It really depends on how you write your code... I ran the following
script on a 150 meg text log file containing 1905883 lines in 4 seconds
(note that it performs caching). Here's the script:

<?php

$path = $argv[1];

if( ($fPtr = fopen( $path, 'r' )) === false )
{
    echo "Couldn't open for reading: $path\n";
    exit();
}

$line = 1;
$lines[$line] = 0;

while( fgets( $fPtr ) !== false )
{
    $lines[++$line] = ftell( $fPtr );
}

fclose( $fPtr );

?>

Here's the run times on several iterations (Athlon 2400+):

real    0m4.065s
user    0m3.488s
sys     0m0.464s

real    0m4.005s
user    0m3.464s
sys     0m0.436s

real    0m5.816s
user    0m3.336s
sys     0m0.536s

real    0m3.994s
user    0m3.384s
sys     0m0.504s

real    0m4.069s
user    0m3.512s
sys     0m0.444s

real    0m4.009s
user    0m3.344s
sys     0m0.552s

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
So the only variation on a theme that I didn't test is the one that performs 
the best by an order of magnitude... nice. Many thanks for your time 
everyone.

"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote:
>> "Richard Heyes" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> >> Thanks for the heads up on fgetc() incrementing by one. I hadn't 
>> >> actually
>> >> tested that code yet, I was using the original fseek($handle,$pos).
>> >>
>> >> strpos would be ideal but it needs to work on a string and not a 
>> >> file - I
>> >> don't want to load a 100Mb file into memory if I don't have to. 
>> >> Perhaps I
>> >> should test how quick the fgets() and ftell() method is because at 
>> >> least
>> >> it loads in one line at a time.
>> >>
>> >> Does anybody know any other ways to go about the problem?
>> >
>> > Haven't read the rest of the thread, and so going by the subject alone,
>> > fgets() finishes when it encounters a newline, so you can use this
>> > wondrous fact to seek to a specific line:
>> >
>> > <?php
>> >     $fp  = fopen('filename', 'r');
>> >     $num = 18; // Desired line number
>> >
>> >     for ($i=0; $i<$num; $i++)
>> >         $line = fgets($fp);
>> >
>> >     echo $line;
>> > ?>
>> >
>> > It works because fgets() stops when it encounters a newline (\n). So 
>> > it's
>> > just a case of counting the calls to fgets().
>>
>> fgets() would work but as I'm constantly jumping around a 500,000 line 
>> file
>> I thought it was better to maintain a cache of line number positions.
>>
>> As a final update to anybody following:
>>
>> - Taking away the unnecessary fseek() made the script execute in 63 
>> seconds
>> - Using a buffer system, (reading in 1Mb of the text file at a time and 
>> then
>> looping through the string in memory) made the script execute in 36 
>> seconds.
>> Huge improvement, but...
>> - Porting the code to C++, doing a shell_exec and reading the results 
>> back
>> in to PHP, took less than 2 seconds.
>>
>> As fgetc() etc are all effectively C wrappers I was quite surprised at 
>> the
>> speed increase....
>
> It really depends on how you write your code... I ran the following
> script on a 150 meg text log file containing 1905883 lines in 4 seconds
> (note that it performs caching). Here's the script:
>
> <?php
>
> $path = $argv[1];
>
> if( ($fPtr = fopen( $path, 'r' )) === false )
> {
>    echo "Couldn't open for reading: $path\n";
>    exit();
> }
>
> $line = 1;
> $lines[$line] = 0;
>
> while( fgets( $fPtr ) !== false )
> {
>    $lines[++$line] = ftell( $fPtr );
> }
>
> fclose( $fPtr );
>
> ?>
>
> Here's the run times on several iterations (Athlon 2400+):
>
> real    0m4.065s
> user    0m3.488s
> sys     0m0.464s
>
> real    0m4.005s
> user    0m3.464s
> sys     0m0.436s
>
> real    0m5.816s
> user    0m3.336s
> sys     0m0.536s
>
> real    0m3.994s
> user    0m3.384s
> sys     0m0.504s
>
> real    0m4.069s
> user    0m3.512s
> sys     0m0.444s
>
> real    0m4.009s
> user    0m3.344s
> sys     0m0.552s
>
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 



--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Sat, 2008-04-05 at 19:09 +0100, Steve McGill wrote:
"Richard Heyes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Thanks for the heads up on fgetc() incrementing by one. I hadn't actually tested that code yet, I was using the original fseek($handle,$pos).

strpos would be ideal but it needs to work on a string and not a file - I don't want to load a 100Mb file into memory if I don't have to. Perhaps I should test how quick the fgets() and ftell() method is because at least it loads in one line at a time.

Does anybody know any other ways to go about the problem?
Haven't read the rest of the thread, and so going by the subject alone, fgets() finishes when it encounters a newline, so you can use this wondrous fact to seek to a specific line:

<?php
    $fp  = fopen('filename', 'r');
    $num = 18; // Desired line number

    for ($i=0; $i<$num; $i++)
        $line = fgets($fp);

    echo $line;
?>

It works because fgets() stops when it encounters a newline (\n). So it's just a case of counting the calls to fgets().
fgets() would work but as I'm constantly jumping around a 500,000 line file I thought it was better to maintain a cache of line number positions.

As a final update to anybody following:

- Taking away the unnecessary fseek() made the script execute in 63 seconds
- Using a buffer system, (reading in 1Mb of the text file at a time and then looping through the string in memory) made the script execute in 36 seconds. Huge improvement, but... - Porting the code to C++, doing a shell_exec and reading the results back in to PHP, took less than 2 seconds.

As fgetc() etc are all effectively C wrappers I was quite surprised at the speed increase....

It really depends on how you write your code... I ran the following
script on a 150 meg text log file containing 1905883 lines in 4 seconds
(note that it performs caching). Here's the script:

<?php

$path = $argv[1];

if( ($fPtr = fopen( $path, 'r' )) === false )
{
    echo "Couldn't open for reading: $path\n";
    exit();
}

$line = 1;
$lines[$line] = 0;

while( fgets( $fPtr ) !== false )
{
    $lines[++$line] = ftell( $fPtr );
}

couldn't you get away from incrementing a counter variable by simply starting the array at index #1 ??

$lines[1] = 0;

while( fgets( $fPtr ) !== false )
{
    $lines[] = ftell( $fPtr );
}

Wouldn't this make it faster?


fclose( $fPtr );

?>

Here's the run times on several iterations (Athlon 2400+):

real    0m4.065s
user    0m3.488s
sys     0m0.464s

real    0m4.005s
user    0m3.464s
sys     0m0.436s

real    0m5.816s
user    0m3.336s
sys     0m0.536s

real    0m3.994s
user    0m3.384s
sys     0m0.504s

real    0m4.069s
user    0m3.512s
sys     0m0.444s

real    0m4.009s
user    0m3.344s
sys     0m0.552s

Cheers,
Rob.


--- End Message ---

Reply via email to