php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26759 some less-than-desirable coding practices
Submitted: 2003-12-31 22:46 UTC Modified: 2004-01-15 20:07 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: kennyt@php.net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kennyt@php.net
New email:
PHP Version: OS:

 

 [2003-12-31 22:46 UTC] kennyt@php.net
Description:
------------
The php.net manual contains lots of examples that use 
less than desirable coding styles, such as unnecessary 
double quotes, concatenation in output (echo 
'foo'.$bar;), bloaty loops (foreach(), which wastes 
memory, when just a while() is needed), etc.

I'm happy to hit a good number of these pages, but I 
don't want to get killed over it. ;-)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-01 01:40 UTC] ben at slax0rnet dot com
I truly can't believe the pickiness present here.  In a lot of these cases the "optimizations" to example code would not equate to any significant gain in performance.
 [2004-01-01 01:47 UTC] kennyt@php.net
Those 'insignificant gains' do add up. Does anyone want 
to teach new PHP developers to [ab]use the language 
like that? [Not meaning to bait any flames; just trying 
to help]

Ignoring any arguments about the necessity in real 
code, does anyone have objections?
 [2004-01-01 04:51 UTC] vrana@php.net
Double quotes and concatenation in output don't cause significant lost in performance. foreach too, furthermore it's better readable than while.

Just my opinion.
 [2004-01-01 05:55 UTC] derick@php.net
Don't smoke too much in the new year please.
 [2004-01-01 13:26 UTC] amaranth at phphacking dot com
I agree that the code examples in the manual teach bad habits. People use them and don't realize there is a better solution, so they write everything with this slower code. Once a script gets large enough these do add up but by then its too late because so many lines would have to be changed. If the manual showed better examples or at least told people about the faster solutions it would fix a lot of headaches.
 [2004-01-01 13:37 UTC] et@php.net
If you write less readable code in PHP because you are counting CPU cycles which most of the time don't even add up to a noticeable amount of time, you are doing something wrong IMHO.


 [2004-01-01 14:24 UTC] vrana@php.net
If there are slow examples in the documentation, point to them. Bad algorithms make scripts slow, not using double quotes where can single quotes be.
 [2004-01-01 17:43 UTC] derick@php.net
leave it at bogus
 [2004-01-15 20:06 UTC] kennyt@php.net
it's a documentation "feature request" :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC