OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 26 Apr 2008 02:44:24 -0000 Issue 5425

php-general-digest-helplists.php.net
Date: Fri Apr 25 2008 - 21:44:24 CDT


php-general Digest 26 Apr 2008 02:44:24 -0000 Issue 5425

Topics (messages 273561 through 273622):

Class Static variables in double quoted string or heredoc
        273561 by: Leurent Francois
        273562 by: Nathan Nobbe
        273563 by: Jason Pruim
        273564 by: Leurent Francois
        273565 by: Nathan Nobbe
        273567 by: Robert Cummings
        273568 by: Nathan Nobbe
        273571 by: Robert Cummings
        273572 by: Eric Butera
        273575 by: Nathan Nobbe
        273576 by: Nathan Nobbe
        273577 by: Robert Cummings
        273579 by: Nathan Nobbe
        273581 by: Nick Stinemates
        273582 by: Nick Stinemates
        273585 by: Robert Cummings
        273587 by: Nathan Nobbe
        273588 by: Nathan Nobbe
        273589 by: Eric Butera
        273590 by: Nathan Nobbe
        273592 by: Nathan Nobbe
        273594 by: Robert Cummings
        273595 by: Nathan Nobbe
        273596 by: Eric Butera
        273597 by: Robert Cummings
        273598 by: Nathan Nobbe
        273599 by: Eric Butera
        273600 by: Eric Butera
        273601 by: Nathan Nobbe
        273602 by: Nathan Nobbe
        273603 by: Eric Butera
        273604 by: Eric Butera
        273605 by: Nathan Nobbe
        273606 by: Nathan Nobbe
        273614 by: Robert Cummings

peer review (was php framework vs just php?)
        273566 by: Jay Blanchard
        273570 by: Robert Cummings
        273573 by: paragasu
        273574 by: Nathan Nobbe
        273618 by: Jay Blanchard
        273619 by: Jay Blanchard
        273620 by: Ray Hauge
        273622 by: Bastien Koert

Re: foreach loop to set variables
        273569 by: jamest
        273607 by: Jim Lucas

Re: php framework vs just php?
        273578 by: Nick Stinemates

Re: the most amazing php code i have ever seen so far
        273580 by: Nick Stinemates
        273583 by: Eric Butera
        273621 by: paragasu

OS need anything for mail() to work?
        273584 by: Brian Dunning
        273586 by: Robert Cummings
        273591 by: Stut
        273593 by: Eric Butera
        273608 by: Jason Pruim
        273609 by: Brian Dunning
        273610 by: Stut
        273611 by: Eric Butera
        273612 by: Brian Dunning
        273613 by: Eric Butera
        273615 by: Shawn McKenzie
        273616 by: Shawn McKenzie
        273617 by: Shawn McKenzie

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Is there any hope that
echo "Welcome {session::$user_info['user_name']}";

will work someday, if not, is there a simple reason i'm missing ?

attached mail follows:


On Fri, Apr 25, 2008 at 9:50 AM, Leurent Francois <131.phpcloudyks.org>
wrote:

> Is there any hope that
> echo "Welcome {session::$user_info['user_name']}";
>
> will work someday, if not, is there a simple reason i'm missing ?

actually, if you see my post from the other day, this is something that
*was* supported in php-5.2.4. i dont know why its not working in 5.2.5; ive
also checked 5.2.6_rc3 and its not working there either. i have written
some phpt tests and run them on a 5.2.4 install and a 5.2.6_rc3 install; you
can find the details on a post to the php-qa list from a couple of days back
(that i posted after a lack of interest from the php-general list :O)

http://marc.info/?l=php-qa&m=120901795414161&w=2

-nathan

attached mail follows:


On Apr 25, 2008, at 11:56 AM, Nathan Nobbe wrote:

> On Fri, Apr 25, 2008 at 9:50 AM, Leurent Francois <131.phpcloudyks.org
> >
> wrote:
>
>> Is there any hope that
>> echo "Welcome {session::$user_info['user_name']}";
>>
>> will work someday, if not, is there a simple reason i'm missing ?
>
>
> actually, if you see my post from the other day, this is something
> that
> *was* supported in php-5.2.4. i dont know why its not working in
> 5.2.5; ive
> also checked 5.2.6_rc3 and its not working there either. i have
> written
> some phpt tests and run them on a 5.2.4 install and a 5.2.6_rc3
> install; you
> can find the details on a post to the php-qa list from a couple of
> days back
> (that i posted after a lack of interest from the php-general list :O)
>
> http://marc.info/?l=php-qa&m=120901795414161&w=2

is there a reason why that would work better then: echo "Welcome
{$_SESSION['user_info']['user_name']}";?

Just curious :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruimraoset.com

attached mail follows:


I like the sess::reload() and sess::connect($user_login,$user_pswd);
idea...

> is there a reason why that would work better then: echo "Welcome
> {$_SESSION['user_info']['user_name']}";?
>
> Just curious :)
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424-9337
> www.raoset.com
> japruimraoset.com
>
>
>

attached mail follows:


On Fri, Apr 25, 2008 at 10:02 AM, Jason Pruim <japruimraoset.com> wrote:

>
> On Apr 25, 2008, at 11:56 AM, Nathan Nobbe wrote:
>
> On Fri, Apr 25, 2008 at 9:50 AM, Leurent Francois <131.phpcloudyks.org>
>> wrote:
>>
>> Is there any hope that
>>> echo "Welcome {session::$user_info['user_name']}";
>>>
>>> will work someday, if not, is there a simple reason i'm missing ?
>>>
>>
>>
>> actually, if you see my post from the other day, this is something that
>> *was* supported in php-5.2.4. i dont know why its not working in 5.2.5;
>> ive
>> also checked 5.2.6_rc3 and its not working there either. i have written
>> some phpt tests and run them on a 5.2.4 install and a 5.2.6_rc3 install;
>> you
>> can find the details on a post to the php-qa list from a couple of days
>> back
>> (that i posted after a lack of interest from the php-general list :O)
>>
>> http://marc.info/?l=php-qa&m=120901795414161&w=2
>>
>
> is there a reason why that would work better then: echo "Welcome
> {$_SESSION['user_info']['user_name']}";?
>
> Just curious :)

i think the question is more along the lines of why cant static references
be embedded within double quoted strings like class instances (and
indirectly the issue i mentioned earlier this week, which affords a
workaround), as in

<?php
class Session { function blah() {} }
$s = new Session();
echo "Hi {$s->blah()} \n";
?>

whereas this doesnt work
<?php
class Session { static function blah() {} }
echo "Hi {Session::blah()} \n";
?>

the funny thing is, in php-5.2.4, you can get away w/ this
<?php
class Session { static function blah() {} }
$s = 'Session';
echo "Hi {$s::blah()} \n";
?>

-nathan

attached mail follows:


On Fri, 2008-04-25 at 10:14 -0600, Nathan Nobbe wrote:
> On Fri, Apr 25, 2008 at 10:02 AM, Jason Pruim <japruimraoset.com> wrote:
>
> >
> > On Apr 25, 2008, at 11:56 AM, Nathan Nobbe wrote:
> >
> > On Fri, Apr 25, 2008 at 9:50 AM, Leurent Francois <131.phpcloudyks.org>
> >> wrote:
> >>
> >> Is there any hope that
> >>> echo "Welcome {session::$user_info['user_name']}";
> >>>
> >>> will work someday, if not, is there a simple reason i'm missing ?
> >>>
> >>
> >>
> >> actually, if you see my post from the other day, this is something that
> >> *was* supported in php-5.2.4. i dont know why its not working in 5.2.5;
> >> ive
> >> also checked 5.2.6_rc3 and its not working there either. i have written
> >> some phpt tests and run them on a 5.2.4 install and a 5.2.6_rc3 install;
> >> you
> >> can find the details on a post to the php-qa list from a couple of days
> >> back
> >> (that i posted after a lack of interest from the php-general list :O)
> >>
> >> http://marc.info/?l=php-qa&m=120901795414161&w=2
> >>
> >
> > is there a reason why that would work better then: echo "Welcome
> > {$_SESSION['user_info']['user_name']}";?
> >
> > Just curious :)
>
>
> i think the question is more along the lines of why cant static references
> be embedded within double quoted strings like class instances (and
> indirectly the issue i mentioned earlier this week, which affords a
> workaround), as in

I think the real question is... why do you guys want to stick a whole
scripting engine into double quotes? There's this thing in PHP, it's
called the concatenation operator... read about it sometime.

*shakes his head* *points at the cavemen* *laughs* Hah hah!

:^

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

attached mail follows:


On Fri, Apr 25, 2008 at 10:53 AM, Robert Cummings <robertinterjinn.com>
wrote:

>
> On Fri, 2008-04-25 at 10:14 -0600, Nathan Nobbe wrote:
> > On Fri, Apr 25, 2008 at 10:02 AM, Jason Pruim <japruimraoset.com>
> wrote:
> >
> > >
> > > On Apr 25, 2008, at 11:56 AM, Nathan Nobbe wrote:
> > >
> > > On Fri, Apr 25, 2008 at 9:50 AM, Leurent Francois <
> 131.phpcloudyks.org>
> > >> wrote:
> > >>
> > >> Is there any hope that
> > >>> echo "Welcome {session::$user_info['user_name']}";
> > >>>
> > >>> will work someday, if not, is there a simple reason i'm missing ?
> > >>>
> > >>
> > >>
> > >> actually, if you see my post from the other day, this is something
> that
> > >> *was* supported in php-5.2.4. i dont know why its not working in
> 5.2.5;
> > >> ive
> > >> also checked 5.2.6_rc3 and its not working there either. i have
> written
> > >> some phpt tests and run them on a 5.2.4 install and a 5.2.6_rc3
> install;
> > >> you
> > >> can find the details on a post to the php-qa list from a couple of
> days
> > >> back
> > >> (that i posted after a lack of interest from the php-general list :O)
> > >>
> > >> http://marc.info/?l=php-qa&m=120901795414161&w=2
> > >>
> > >
> > > is there a reason why that would work better then: echo "Welcome
> > > {$_SESSION['user_info']['user_name']}";?
> > >
> > > Just curious :)
> >
> >
> > i think the question is more along the lines of why cant static
> references
> > be embedded within double quoted strings like class instances (and
> > indirectly the issue i mentioned earlier this week, which affords a
> > workaround), as in
>
> I think the real question is... why do you guys want to stick a whole
> scripting engine into double quotes? There's this thing in PHP, it's
> called the concatenation operator... read about it sometime.
>
> *shakes his head* *points at the cavemen* *laughs* Hah hah!

bah; concatenation operator - schmacatatenation operator! i dont really
care about that; but i would like to see support for $a::$someStatic come
back. thats what im whining about ;)

-nathan

attached mail follows:


On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
>
> bah; concatenation operator - schmacatatenation operator! i dont really
> care about that; but i would like to see support for $a::$someStatic come
> back. thats what im whining about ;)

That funny part, IMHO, is that on internals they often complain about
new features not being simple enough for the supposed mentally incapable
masses. And yet there's support for this kind of double quoting stuff
that just makes me think poor form, bad style, and where's my t-shirt.

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

attached mail follows:


On Fri, Apr 25, 2008 at 12:55 PM, Nathan Nobbe <quickshiftingmail.com> wrote:
> i would like to see support for $a::$someStatic come

callback :P

http://us.php.net/manual/en/function.call-user-func-array.php

attached mail follows:


On Fri, Apr 25, 2008 at 11:01 AM, Robert Cummings <robertinterjinn.com>
wrote:

> On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
> >
> > bah; concatenation operator - schmacatatenation operator! i dont really
> > care about that; but i would like to see support for $a::$someStatic come
> > back. thats what im whining about ;)
>
> That funny part, IMHO, is that on internals they often complain about
> new features not being simple enough for the supposed mentally incapable
> masses. And yet there's support for this kind of double quoting stuff
> that just makes me think poor form, bad style, and where's my t-shirt.

are you saying this feature is too esoteric for you ? :)

besides i didnt create the double quoted support and thats not even what im
arguing about anyway. the syntax ive mentioned was there in a pre-5.2.4
release (discovered it didnt actually make the cut for the 5.2.4) it save
you from having to write ugly little helper methods and thats a benefit i
wouldnt mind having.

php has a great dilema, it wants to cater to a wide range of users; from
newbs to experts. thats a massive undertaking and well if youre gonna do
it, you may as well go whole-hog IMHO.

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 11:02 AM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 12:55 PM, Nathan Nobbe <quickshiftingmail.com>
> wrote:
> > i would like to see support for $a::$someStatic come
>
> callback :P
>
> http://us.php.net/manual/en/function.call-user-func-array.php
>

workaround-smerkaround :P

-nathan

attached mail follows:


On Fri, 2008-04-25 at 11:11 -0600, Nathan Nobbe wrote:
> On Fri, Apr 25, 2008 at 11:01 AM, Robert Cummings <robertinterjinn.com>
> wrote:
>
> > On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
> > >
> > > bah; concatenation operator - schmacatatenation operator! i dont really
> > > care about that; but i would like to see support for $a::$someStatic come
> > > back. thats what im whining about ;)
> >
> > That funny part, IMHO, is that on internals they often complain about
> > new features not being simple enough for the supposed mentally incapable
> > masses. And yet there's support for this kind of double quoting stuff
> > that just makes me think poor form, bad style, and where's my t-shirt.
>
>
> are you saying this feature is too esoteric for you ? :)

No, it's too, hmmm... what's the word... REDUNDANT!

:)

> besides i didnt create the double quoted support and thats not even what im
> arguing about anyway. the syntax ive mentioned was there in a pre-5.2.4
> release (discovered it didnt actually make the cut for the 5.2.4) it save
> you from having to write ugly little helper methods and thats a benefit i
> wouldnt mind having.

There's a reason they call it "pre-release". It means it's not
"final" ;)

> php has a great dilema, it wants to cater to a wide range of users; from
> newbs to experts. thats a massive undertaking and well if youre gonna do
> it, you may as well go whole-hog IMHO.

I don't see how the throwing everything and the kitchen sink into double
quotes support caters to either of these groups. It strikes me, and of
course that's who matters here >:), that it caters to the messy, "I wish
I REALLY knew what I was doing", slovenly crowd.

Just because a feature exists, doesn't mean you should use it!

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

attached mail follows:


On Fri, Apr 25, 2008 at 11:19 AM, Robert Cummings <robertinterjinn.com>
wrote:

>
> On Fri, 2008-04-25 at 11:11 -0600, Nathan Nobbe wrote:
> > On Fri, Apr 25, 2008 at 11:01 AM, Robert Cummings <robertinterjinn.com>
> > wrote:
> >
> > > On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
> > > >
> > > > bah; concatenation operator - schmacatatenation operator! i dont
> really
> > > > care about that; but i would like to see support for $a::$someStatic
> come
> > > > back. thats what im whining about ;)
> > >
> > > That funny part, IMHO, is that on internals they often complain about
> > > new features not being simple enough for the supposed mentally
> incapable
> > > masses. And yet there's support for this kind of double quoting stuff
> > > that just makes me think poor form, bad style, and where's my t-shirt.
> >
> >
> > are you saying this feature is too esoteric for you ? :)
>
> No, it's too, hmmm... what's the word... REDUNDANT!
>
> :)
>

actually, its a little cleaner if you ask me. infact i think being able to
delimit strings in either single or double quotes was a precursor to this.
example: java; if i want to have double quotes in a string i *have* to
escape them w/in the string \". in php or javascript; i simply delimit the
string w/ single quotes. this feature is simply an evolution of that
concept, IMHO.

> besides i didnt create the double quoted support and thats not even what
im
> arguing about anyway. the syntax ive mentioned was there in a pre-5.2.4
> release (discovered it didnt actually make the cut for the 5.2.4) it save
> you from having to write ugly little helper methods and thats a benefit i
> wouldnt mind having.

There's a reason they call it "pre-release". It means it's not
> "final" ;)
>

what the world needs is a term for the 'pre-release' being cooler than the
release ;)

> php has a great dilema, it wants to cater to a wide range of users; from
> newbs to experts. thats a massive undertaking and well if youre gonna do
> it, you may as well go whole-hog IMHO.

I don't see how the throwing everything and the kitchen sink into double
> quotes support caters to either of these groups. It strikes me, and of
> course that's who matters here >:),

i matter more !:D

> that it caters to the messy, "I wish
> I REALLY knew what I was doing", slovenly crowd.
>

if you dont know about the concatenation operator my thought is you wont be
going far w/ php or any other language for that matter :)

Just because a feature exists, doesn't mean you should use it!
>

here we are back at the classic syntactic sugar argument. at least weve
moved past abstract classes and interfaces !

good times :D

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
>
> I don't see how the throwing everything and the kitchen sink into double
> quotes support caters to either of these groups. It strikes me, and of
> course that's who matters here >:), that it caters to the messy, "I wish
> I REALLY knew what I was doing", slovenly crowd.
>
> Just because a feature exists, doesn't mean you should use it!
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP

Agree, and couldn't imagine working with someones code where they
liberally use these types of lazy things. I like structured, ordered
code, and, somehow, using something like this technique doesn't seem
structured or ordered.

--
Nick Stinemates (nickstinemates.org)
http://nick.stinemates.org

attached mail follows:


On Fri, Apr 25, 2008 at 11:29:05AM -0600, Nathan Nobbe wrote:
> here we are back at the classic syntactic sugar argument. at least weve
> moved past abstract classes and interfaces !

for now........ :)

--
Nick Stinemates (nickstinemates.org)
http://nick.stinemates.org

attached mail follows:


On Fri, 2008-04-25 at 11:29 -0600, Nathan Nobbe wrote:
> On Fri, Apr 25, 2008 at 11:19 AM, Robert Cummings <robertinterjinn.com>
> wrote:
>
> >
> > On Fri, 2008-04-25 at 11:11 -0600, Nathan Nobbe wrote:
> > > On Fri, Apr 25, 2008 at 11:01 AM, Robert Cummings <robertinterjinn.com>
> > > wrote:
> > >
> > > > On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
> > > > >
> > > > > bah; concatenation operator - schmacatatenation operator! i dont
> > really
> > > > > care about that; but i would like to see support for $a::$someStatic
> > come
> > > > > back. thats what im whining about ;)
> > > >
> > > > That funny part, IMHO, is that on internals they often complain about
> > > > new features not being simple enough for the supposed mentally
> > incapable
> > > > masses. And yet there's support for this kind of double quoting stuff
> > > > that just makes me think poor form, bad style, and where's my t-shirt.
> > >
> > >
> > > are you saying this feature is too esoteric for you ? :)
> >
> > No, it's too, hmmm... what's the word... REDUNDANT!
> >
> > :)
> >
>
> actually, its a little cleaner if you ask me. infact i think being able to
> delimit strings in either single or double quotes was a precursor to this.
> example: java; if i want to have double quotes in a string i *have* to
> escape them w/in the string \". in php or javascript; i simply delimit the
> string w/ single quotes. this feature is simply an evolution of that
> concept, IMHO.

Oh, I greatly see the utility in having support for both single and
double quoted strings. I just don't see the utility in supporting
"everything under the sun" expansion within double quotes.

> > besides i didnt create the double quoted support and thats not even what
> im
> > arguing about anyway. the syntax ive mentioned was there in a pre-5.2.4
> > release (discovered it didnt actually make the cut for the 5.2.4) it save
> > you from having to write ugly little helper methods and thats a benefit i
> > wouldnt mind having.
>
> There's a reason they call it "pre-release". It means it's not
> > "final" ;)
> >
>
> what the world needs is a term for the 'pre-release' being cooler than the
> release ;)
>
> > php has a great dilema, it wants to cater to a wide range of users; from
> > newbs to experts. thats a massive undertaking and well if youre gonna do
> > it, you may as well go whole-hog IMHO.
>
> I don't see how the throwing everything and the kitchen sink into double
> > quotes support caters to either of these groups. It strikes me, and of
> > course that's who matters here >:),
>
> i matter more !:D
>
> > that it caters to the messy, "I wish
> > I REALLY knew what I was doing", slovenly crowd.
>
> if you dont know about the concatenation operator my thought is you wont be
> going far w/ php or any other language for that matter :)
>
> Just because a feature exists, doesn't mean you should use it!
> >
>
> here we are back at the classic syntactic sugar argument. at least weve
> moved past abstract classes and interfaces !
>
> good times :D

Funny you should mention that, I was going to add a reference to
interfaces and abstract classes when I mentioned that ;)

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

attached mail follows:


On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <nickstinemates.org>
wrote:

> On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> >
> > I don't see how the throwing everything and the kitchen sink into double
> > quotes support caters to either of these groups. It strikes me, and of
> > course that's who matters here >:), that it caters to the messy, "I wish
> > I REALLY knew what I was doing", slovenly crowd.
> >
> > Just because a feature exists, doesn't mean you should use it!
> >
> > Cheers,
> > Rob.
> > --
> > http://www.interjinn.com
> > Application and Templating Framework for PHP
>
> Agree, and couldn't imagine working with someones code where they
> liberally use these types of lazy things. I like structured, ordered
> code, and, somehow, using something like this technique doesn't seem
> structured or ordered.

to each his own; as i said personally, i consider those *more* structured
than the concatenation operator, when they work ;) but anyway, i got lured
into the argument for parsing variables and function calls in double
quotes. i have been arguing for the $className::$staticMember feature which
i piggybacked into this conversation because of a lack of response on a
previous post from this week. and just to pour gas on the fire, if you guys
want to know a syntactic sugar feature i avoid like the plague, its the
ternary operator!

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 11:37 AM, Nick Stinemates <nickstinemates.org>
wrote:

> On Fri, Apr 25, 2008 at 11:29:05AM -0600, Nathan Nobbe wrote:
> > here we are back at the classic syntactic sugar argument. at least weve
> > moved past abstract classes and interfaces !
>
> for now........ :)

heh, ready whenever :)

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 2:25 PM, Nathan Nobbe <quickshiftingmail.com> wrote:
> want to know a syntactic sugar feature i avoid like the plague, its the
> ternary operator!

Like this?

return (!is_dir($indexPath))
        ? Zend_Search_Lucene::create($indexPath)
        : Zend_Search_Lucene::open($indexPath);

;)

attached mail follows:


On Fri, Apr 25, 2008 at 12:21 PM, Robert Cummings <robertinterjinn.com>
wrote:

>
> On Fri, 2008-04-25 at 11:29 -0600, Nathan Nobbe wrote:
> > On Fri, Apr 25, 2008 at 11:19 AM, Robert Cummings <robertinterjinn.com>
> > wrote:
> >
> > >
> > > On Fri, 2008-04-25 at 11:11 -0600, Nathan Nobbe wrote:
> > > > On Fri, Apr 25, 2008 at 11:01 AM, Robert Cummings <
> robertinterjinn.com>
> > > > wrote:
> > > >
> > > > > On Fri, 2008-04-25 at 10:55 -0600, Nathan Nobbe wrote:
> > > > > >
> > > > > > bah; concatenation operator - schmacatatenation operator! i dont
> > > really
> > > > > > care about that; but i would like to see support for
> $a::$someStatic
> > > come
> > > > > > back. thats what im whining about ;)
> > > > >
> > > > > That funny part, IMHO, is that on internals they often complain
> about
> > > > > new features not being simple enough for the supposed mentally
> > > incapable
> > > > > masses. And yet there's support for this kind of double quoting
> stuff
> > > > > that just makes me think poor form, bad style, and where's my
> t-shirt.
> > > >
> > > >
> > > > are you saying this feature is too esoteric for you ? :)
> > >
> > > No, it's too, hmmm... what's the word... REDUNDANT!
> > >
> > > :)
> > >
> >
> > actually, its a little cleaner if you ask me. infact i think being able
> to
> > delimit strings in either single or double quotes was a precursor to
> this.
> > example: java; if i want to have double quotes in a string i *have* to
> > escape them w/in the string \". in php or javascript; i simply delimit
> the
> > string w/ single quotes. this feature is simply an evolution of that
> > concept, IMHO.
>
> Oh, I greatly see the utility in having support for both single and
> double quoted strings. I just don't see the utility in supporting
> "everything under the sun" expansion within double quotes.

i hear you there; and i actually wasnt arguing for support of a wider range
of tokens to be supported within double quotes. all i was saying is that if
php had a feature that was in the 'pre-release' of 5.2.4 and will be in 5.3
anyway there is a workaround that gets you the ability with the current
double string variable / function call resolving support.

> > besides i didnt create the double quoted support and thats not even what
> > im
> > > arguing about anyway. the syntax ive mentioned was there in a
> pre-5.2.4
> > > release (discovered it didnt actually make the cut for the 5.2.4) it
> save
> > > you from having to write ugly little helper methods and thats a benefit
> i
> > > wouldnt mind having.
> >
> > There's a reason they call it "pre-release". It means it's not
> > > "final" ;)
> > >
> >
> > what the world needs is a term for the 'pre-release' being cooler than
> the
> > release ;)
> >
> > > php has a great dilema, it wants to cater to a wide range of users;
> from
> > > newbs to experts. thats a massive undertaking and well if youre gonna
> do
> > > it, you may as well go whole-hog IMHO.
> >
> > I don't see how the throwing everything and the kitchen sink into double
> > > quotes support caters to either of these groups. It strikes me, and of
> > > course that's who matters here >:),
> >
> > i matter more !:D
> >
> > > that it caters to the messy, "I wish
> > > I REALLY knew what I was doing", slovenly crowd.
> >
> > if you dont know about the concatenation operator my thought is you wont
> be
> > going far w/ php or any other language for that matter :)
> >
> > Just because a feature exists, doesn't mean you should use it!
> > >
> >
> > here we are back at the classic syntactic sugar argument. at least weve
> > moved past abstract classes and interfaces !
> >
> > good times :D
>
> Funny you should mention that, I was going to add a reference to
> interfaces and abstract classes when I mentioned that ;)

and im sure that in the infamous words of tony marston, we would inevitably
'agree to disagree' :)

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 12:28 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 2:25 PM, Nathan Nobbe <quickshiftingmail.com>
> wrote:
> > want to know a syntactic sugar feature i avoid like the plague, its the
> > ternary operator!
>
> Like this?
>
> return (!is_dir($indexPath))
> ? Zend_Search_Lucene::create($indexPath)
> : Zend_Search_Lucene::open($indexPath);
>
> ;)
>

u got it ;)

-nathan

attached mail follows:


On Fri, 2008-04-25 at 12:25 -0600, Nathan Nobbe wrote:
> On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <nickstinemates.org>
> wrote:
>
> > On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> > >
> > > I don't see how the throwing everything and the kitchen sink into double
> > > quotes support caters to either of these groups. It strikes me, and of
> > > course that's who matters here >:), that it caters to the messy, "I wish
> > > I REALLY knew what I was doing", slovenly crowd.
> > >
> > > Just because a feature exists, doesn't mean you should use it!
> > >
> > > Cheers,
> > > Rob.
> > > --
> > > http://www.interjinn.com
> > > Application and Templating Framework for PHP
> >
> > Agree, and couldn't imagine working with someones code where they
> > liberally use these types of lazy things. I like structured, ordered
> > code, and, somehow, using something like this technique doesn't seem
> > structured or ordered.
>
>
> to each his own; as i said personally, i consider those *more* structured
> than the concatenation operator, when they work ;) but anyway, i got lured
> into the argument for parsing variables and function calls in double
> quotes. i have been arguing for the $className::$staticMember

Well, I certainly don't have a problem with $className::$staticMember.
But then, we ween't talking about that, were we! :)

> i piggybacked into this conversation because of a lack of response on a
> previous post from this week. and just to pour gas on the fire, if you guys
> want to know a syntactic sugar feature i avoid like the plague, its the
> ternary operator!

I find it succinct for short evaluations... such as getting a $_GET
entry whether it exists or not.

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

attached mail follows:


On Fri, Apr 25, 2008 at 12:36 PM, Robert Cummings <robertinterjinn.com>
wrote:

>
> On Fri, 2008-04-25 at 12:25 -0600, Nathan Nobbe wrote:
> > On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <nickstinemates.org>
> > wrote:
> >
> > > On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> > > >
> > > > I don't see how the throwing everything and the kitchen sink into
> double
> > > > quotes support caters to either of these groups. It strikes me, and
> of
> > > > course that's who matters here >:), that it caters to the messy, "I
> wish
> > > > I REALLY knew what I was doing", slovenly crowd.
> > > >
> > > > Just because a feature exists, doesn't mean you should use it!
> > > >
> > > > Cheers,
> > > > Rob.
> > > > --
> > > > http://www.interjinn.com
> > > > Application and Templating Framework for PHP
> > >
> > > Agree, and couldn't imagine working with someones code where they
> > > liberally use these types of lazy things. I like structured, ordered
> > > code, and, somehow, using something like this technique doesn't seem
> > > structured or ordered.
> >
> >
> > to each his own; as i said personally, i consider those *more* structured
> > than the concatenation operator, when they work ;) but anyway, i got
> lured
> > into the argument for parsing variables and function calls in double
> > quotes. i have been arguing for the $className::$staticMember
>
> Well, I certainly don't have a problem with $className::$staticMember.
> But then, we ween't talking about that, were we! :)

i know; i tried to sneak it in to no avail; heh. anyway, no matter, i
finally got a reply on the qa list.

> > i piggybacked into this conversation because of a lack of response on a
> > previous post from this week. and just to pour gas on the fire, if you
> guys
> > want to know a syntactic sugar feature i avoid like the plague, its the
> > ternary operator!
>
>
> I find it succinct for short evaluations... such as getting a $_GET
> entry whether it exists or not.

ya; i know they have uses and (keep it on the dl) i have been known to use
them as well, rarely. but theyve grown on me a little since my initial
blanket hatred of them. more than anything i was just trying to stir things
up a bit :D

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 2:36 PM, Robert Cummings <robertinterjinn.com> wrote:
>
> On Fri, 2008-04-25 at 12:25 -0600, Nathan Nobbe wrote:
> > On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <nickstinemates.org>
> > wrote:
> >
> > > On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> > > >
> > > > I don't see how the throwing everything and the kitchen sink into double
> > > > quotes support caters to either of these groups. It strikes me, and of
> > > > course that's who matters here >:), that it caters to the messy, "I wish
> > > > I REALLY knew what I was doing", slovenly crowd.
> > > >
> > > > Just because a feature exists, doesn't mean you should use it!
> > > >
> > > > Cheers,
> > > > Rob.
> > > > --
> > > > http://www.interjinn.com
> > > > Application and Templating Framework for PHP
> > >
> > > Agree, and couldn't imagine working with someones code where they
> > > liberally use these types of lazy things. I like structured, ordered
> > > code, and, somehow, using something like this technique doesn't seem
> > > structured or ordered.
> >
> >
> > to each his own; as i said personally, i consider those *more* structured
> > than the concatenation operator, when they work ;) but anyway, i got lured
> > into the argument for parsing variables and function calls in double
> > quotes. i have been arguing for the $className::$staticMember
>
> Well, I certainly don't have a problem with $className::$staticMember.
> But then, we ween't talking about that, were we! :)
>
>
> > i piggybacked into this conversation because of a lack of response on a
> > previous post from this week. and just to pour gas on the fire, if you guys
> > want to know a syntactic sugar feature i avoid like the plague, its the
> > ternary operator!
>
> I find it succinct for short evaluations... such as getting a $_GET
> entry whether it exists or not.
>
>
> 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
>
>

You know... this topic hasn't been approached from the security angle
either. Best practices indicates all output should be properly
escaped based on the context it is going to be used in. So unless
that whole string is going to be escaped or a strong application level
filter using ext/filter is in place this should really be broken into
printf("Welcome %s",
htmlspecialchars(session::$user_info['user_name'], ENT_QUOTES));,
right? ;D

attached mail follows:


On Fri, 2008-04-25 at 14:44 -0400, Eric Butera wrote:
> On Fri, Apr 25, 2008 at 2:36 PM, Robert Cummings <robertinterjinn.com> wrote:
> >
> > On Fri, 2008-04-25 at 12:25 -0600, Nathan Nobbe wrote:
> > > On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <nickstinemates.org>
> > > wrote:
> > >
> > > > On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> > > > >
> > > > > I don't see how the throwing everything and the kitchen sink into double
> > > > > quotes support caters to either of these groups. It strikes me, and of
> > > > > course that's who matters here >:), that it caters to the messy, "I wish
> > > > > I REALLY knew what I was doing", slovenly crowd.
> > > > >
> > > > > Just because a feature exists, doesn't mean you should use it!
> > > > >
> > > > > Cheers,
> > > > > Rob.
> > > > > --
> > > > > http://www.interjinn.com
> > > > > Application and Templating Framework for PHP
> > > >
> > > > Agree, and couldn't imagine working with someones code where they
> > > > liberally use these types of lazy things. I like structured, ordered
> > > > code, and, somehow, using something like this technique doesn't seem
> > > > structured or ordered.
> > >
> > >
> > > to each his own; as i said personally, i consider those *more* structured
> > > than the concatenation operator, when they work ;) but anyway, i got lured
> > > into the argument for parsing variables and function calls in double
> > > quotes. i have been arguing for the $className::$staticMember
> >
> > Well, I certainly don't have a problem with $className::$staticMember.
> > But then, we ween't talking about that, were we! :)
> >
> >
> > > i piggybacked into this conversation because of a lack of response on a
> > > previous post from this week. and just to pour gas on the fire, if you guys
> > > want to know a syntactic sugar feature i avoid like the plague, its the
> > > ternary operator!
> >
> > I find it succinct for short evaluations... such as getting a $_GET
> > entry whether it exists or not.
> >
> >
> > 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
> >
> >
>
> You know... this topic hasn't been approached from the security angle
> either. Best practices indicates all output should be properly
> escaped based on the context it is going to be used in. So unless
> that whole string is going to be escaped or a strong application level
> filter using ext/filter is in place this should really be broken into
> printf("Welcome %s",
> htmlspecialchars(session::$user_info['user_name'], ENT_QUOTES));,
> right? ;D

Why would anyone use htmlspecialchars() on a shell script?

>:)

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

attached mail follows:


On Fri, Apr 25, 2008 at 12:44 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 2:36 PM, Robert Cummings <robertinterjinn.com>
> wrote:
> >
> > On Fri, 2008-04-25 at 12:25 -0600, Nathan Nobbe wrote:
> > > On Fri, Apr 25, 2008 at 11:35 AM, Nick Stinemates <
> nickstinemates.org>
> > > wrote:
> > >
> > > > On Fri, Apr 25, 2008 at 01:19:58PM -0400, Robert Cummings wrote:
> > > > >
> > > > > I don't see how the throwing everything and the kitchen sink into
> double
> > > > > quotes support caters to either of these groups. It strikes me,
> and of
> > > > > course that's who matters here >:), that it caters to the messy,
> "I wish
> > > > > I REALLY knew what I was doing", slovenly crowd.
> > > > >
> > > > > Just because a feature exists, doesn't mean you should use it!
> > > > >
> > > > > Cheers,
> > > > > Rob.
> > > > > --
> > > > > http://www.interjinn.com
> > > > > Application and Templating Framework for PHP
> > > >
> > > > Agree, and couldn't imagine working with someones code where they
> > > > liberally use these types of lazy things. I like structured, ordered
> > > > code, and, somehow, using something like this technique doesn't seem
> > > > structured or ordered.
> > >
> > >
> > > to each his own; as i said personally, i consider those *more*
> structured
> > > than the concatenation operator, when they work ;) but anyway, i got
> lured
> > > into the argument for parsing variables and function calls in double
> > > quotes. i have been arguing for the $className::$staticMember
> >
> > Well, I certainly don't have a problem with $className::$staticMember.
> > But then, we ween't talking about that, were we! :)
> >
> >
> > > i piggybacked into this conversation because of a lack of response on
> a
> > > previous post from this week. and just to pour gas on the fire, if
> you guys
> > > want to know a syntactic sugar feature i avoid like the plague, its
> the
> > > ternary operator!
> >
> > I find it succinct for short evaluations... such as getting a $_GET
> > entry whether it exists or not.
> >
> >
> > 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
> >
> >
>
> You know... this topic hasn't been approached from the security angle
> either. Best practices indicates all output should be properly
> escaped based on the context it is going to be used in. So unless
> that whole string is going to be escaped or a strong application level
> filter using ext/filter is in place this should really be broken into
> printf("Welcome %s",
> htmlspecialchars(session::$user_info['user_name'], ENT_QUOTES));,
> right? ;D
>

just to play devils advocate; it could still be crammed into double quotes,

<?php

class Session {
    public $users = array();
}

class OutputEscaper {
    function escapeStuff($stuff) {
        return htmlspecialchars($stuff);
    }
}

$s = new Session();
$oe = new OutputEscaper();

$s->users['user_name'] = 'some dude';

echo "Hi {$oe->escapeStuff($s->users['user_name'])}\n";
?>

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 2:50 PM, Robert Cummings <robertinterjinn.com> wrote:
> Why would anyone use htmlspecialchars() on a shell script?
>
> >:)

Who uses a session in a cli script?

attached mail follows:


On Fri, Apr 25, 2008 at 2:51 PM, Nathan Nobbe <quickshiftingmail.com> wrote:
> class OutputEscaper {

I dunno man. I have an escape() method on different classes such as
View (which can be told to use htmlspecialchars/entities), DB, etc.
This way you know you're doing $view->escape() or $db->escape()
instead of some generic thing. I think it helps me realize the
context a bit more than a stand-alone escaper that doesn't know the
details of what database I'm using or my target x/html output.

You could then argue that if you're trying to output user values in
HTML you should be working with something like htmlpurifier anyways.
But there are only so many hours in the day...

But back to the original point, you're cheating because you have
instances there, not static calls! :P

attached mail follows:


On Fri, Apr 25, 2008 at 12:52 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 2:50 PM, Robert Cummings <robertinterjinn.com>
> wrote:
> > Why would anyone use htmlspecialchars() on a shell script?
> >
> > >:)
>
> Who uses a session in a cli script?
>

i do; that way when the script terminates the session is wiped clean :D

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 1:08 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 2:51 PM, Nathan Nobbe <quickshiftingmail.com>
> wrote:
> > class OutputEscaper {
>
> I dunno man. I have an escape() method on different classes such as
> View (which can be told to use htmlspecialchars/entities), DB, etc.
> This way you know you're doing $view->escape() or $db->escape()
> instead of some generic thing. I think it helps me realize the
> context a bit more than a stand-alone escaper that doesn't know the
> details of what database I'm using or my target x/html output.

meh; just make sure the instance holds what you want it to; it was just a
contrived example to illustrate the syntax supported in double quotes,
currently.

You could then argue that if you're trying to output user values in
> HTML you should be working with something like htmlpurifier anyways.
> But there are only so many hours in the day...

this techie burns the candle at both ends :)

But back to the original point, you're cheating because you have
> instances there, not static calls! :P
>

heh, right; just holding my breath for php-5.3!

-nathan

attached mail follows:


On Fri, Apr 25, 2008 at 3:09 PM, Nathan Nobbe <quickshiftingmail.com> wrote:
> i do; that way when the script terminates the session is wiped clean :D

$GLOBALS would get you the same thing a lot easier. I've had to use
sessions in cli before just because I converted some old front-end
scripts that used to be spawned via a cron curl directly to CLI. So I
guess I can see it happening sometimes. *shrug*

attached mail follows:


On Fri, Apr 25, 2008 at 3:12 PM, Nathan Nobbe <quickshiftingmail.com> wrote:
> meh; just make sure the instance holds what you want it to; it was just a
> contrived example to illustrate the syntax supported in double quotes,
> currently.

I know, I'm just goofing around on Friday. ;)

attached mail follows:


On Fri, Apr 25, 2008 at 1:14 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 3:09 PM, Nathan Nobbe <quickshiftingmail.com>
> wrote:
> > i do; that way when the script terminates the session is wiped clean :D
>
> $GLOBALS would get you the same thing a lot easier. I've had to use
> sessions in cli before just because I converted some old front-end
> scripts that used to be spawned via a cron curl directly to CLI. So I
> guess I can see it happening sometimes. *shrug*
>

it was a joke :P

attached mail follows:


On Fri, Apr 25, 2008 at 1:16 PM, Eric Butera <eric.buteragmail.com> wrote:

> On Fri, Apr 25, 2008 at 3:12 PM, Nathan Nobbe <quickshiftingmail.com>
> wrote:
> > meh; just make sure the instance holds what you want it to; it was just a
> > contrived example to illustrate the syntax supported in double quotes,
> > currently.
>
> I know, I'm just goofing around on Friday. ;)
>

and i say again; good-times :D

attached mail follows:


On Fri, 2008-04-25 at 14:52 -0400, Eric Butera wrote:
> On Fri, Apr 25, 2008 at 2:50 PM, Robert Cummings <robertinterjinn.com> wrote:
> > Why would anyone use htmlspecialchars() on a shell script?
> >
> > >:)
>
> Who uses a session in a cli script?

Cron to destroy any expired sessions.

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

attached mail follows:


I did a quick and dirty of just one of those functions. This function
takes a table and creates a form based on the table. It needs quite a
bit of refining, but I am willing to share and let you guys and gals
throw suggestions;

function formCreate($database, $table, $action, $excludeCols,
$recordID){
        /*
         * This function is used to create forms on the fly based on
tables within
         * the database. The minimal arguments are database name and
table name.
         * Additional arguements may be supplied to indicate columns to
be excluded
         * from form and an action (CRUD) to be performed once the form
         * is filled out. If wanting to do an update, read or delete you
can specify
         * a record to retrieve to populate the form. Default values
will be provided
         * for arguements not included.
         */
         /* database connection in global variable */
         global $dc;
         /* number of arguements sent to function */
         $numArgs = func_num_args();
         /* test to make sure that you have the minial two arguements */
         if(2 > $numArgs){
                 /* not enough arguments */
                 $errMsg = "not enough arguements supplied, please supply
database and table name";
                 return($errMsg);
         } else {
                 /*
                  * Supply default values for optional arguements if they
are not set.
                  * An interesting note here: the action can be anything
that the user
                  * specifies, it is not strictly limited to CRUD and it
will be output
                  * in a hidden form field;
                  * <input type="hidden" name="action" value="whatever
action is called">
                  * That way when the user clicks 'Submit' the programmer
can have a
                  * switch action in his or her processing script to
handle this form.
                  */
                  if(!isset($action)) { $action = 'read'; }
                  if(!isset($recordID)) { $recordID = ''; }
                  if(!isset($excludeCols)){
                          $excludeCols = '';
                  } else {
                          /* create an array of excluded columns */
                          $arrExcludeCols = explode(",", $excludeCols);
                  }
                 
                 /* describe the table */
                 $sqlDesc = "DESCRIBE `".$database."`.`".$table."` ";
                 if(!($dbInfo = mysql_query($sqlDesc, $dc))){
                         return mysql_error();
                 } else {
                         while($tableInfo = mysql_fetch_array($dbInfo)){
                                /*
                                 * regular expression - we need the data
that exists between the
                                 * parentheses in the Type column of the
database being described
                                 * so that we can use for length values
of form fields
                                 */
                                 if(!(in_array($tableInfo['Field'],
$arrExcludeCols))){
                                         if(preg_match (
"/\((\d{1,}.*?)\)/", $tableInfo[1], $regs )){
                                                /* handle numerical
values in parentheses to create form element lengths */
                                                   echo
"<label>".$tableInfo['Field']."</label>";
                                                echo "<input
type=\"text\" name=\"".$tableInfo['Field']."\" size=\"".$regs[1]."\"
maxlength=\"".$regs[1]."\"><br />\n";
                                        } elseif("text" ==
$tableInfo[1]) {
                                                /* handle text columns
*/
                                                echo
"<label>".$tableInfo['Field']."</label>";
                                                echo "<textarea
name=\"".$tableInfo['Field']."\" cols=\"80\" rows=\"10\"></textarea><br
/>\n";
                                        } elseif("enum" ==
substr($tableInfo[1], 0, 4)){
                                                /* handle enumerated
columns and creat drop downs */
                                                echo
"<label>".$tableInfo['Field']."</label>&nbsp;";
                                                /*
                                                 * regular expression -
we need the data that
                                                 * exists between the
single quotes in the Type column of the
                                                 * database being
described so that we can use for option
                                                 * values in a drop-down
on the form
                                                 */
                                                preg_match_all(
"/'(.*)'/U", $tableInfo[1], $matches);
                                                echo "<select
name=\"".$tableInfo['Field']."\">\n";
                                                echo
"<option></option>\n";
                                                for($i = 0; $i <
count($matches[1]); $i++){
                                                        echo
"<option>".$matches[1][$i]."</option>\n";
                                                }
                                                echo "</select><br
/>\n";
                                        }//end if preg
                                 }//end if in_array
                         }//end while tableInfo
                         /* set up the hidden action field */
                         echo "<input type=\"hidden\" name=\"action\"
value=\"".$action."\">\n";
                         /* provide a submit and reset button */
                         echo "<input type=\"submit\" name=\"submit\"
value=\"Submit\">&nbsp;&nbsp;";
                         echo "<input type=\"reset\" name=\"reset\"
value=\"Clear\"><br />\n";
                         return;
                 }// end if dbInfo
        }// end if numArgs
}//end function formCreate

With this I need one function call to create the form on the page. I can
exclude columns and set an action to be taken once the form is filled
out.

There are several other functions and what I end up with is a set of
functions that do make up a form handling framework. This can also be
done in the context of OOP, I just want to show some procedural code.
This assumes MySQL as the database.

Let the laughter begin.....

attached mail follows:


On Fri, 2008-04-25 at 11:17 -0500, Jay Blanchard wrote:
> I did a quick and dirty of just one of those functions. This function
> takes a table and creates a form based on the table. It needs quite a
> bit of refining, but I am willing to share and let you guys and gals
> throw suggestions;
>
> function formCreate($database, $table, $action, $excludeCols,
> $recordID){
> /*
> * This function is used to create forms on the fly based on
> tables within
> * the database. The minimal arguments are database name and
> table name.
> * Additional arguements may be supplied to indicate columns to
> be excluded
> * from form and an action (CRUD) to be performed once the form
> * is filled out. If wanting to do an update, read or delete you
> can specify
> * a record to retrieve to populate the form. Default values
> will be provided
> * for arguements not included.
> */
> /* database connection in global variable */
> global $dc;
> /* number of arguements sent to function */
> $numArgs = func_num_args();
> /* test to make sure that you have the minial two arguements */
> if(2 > $numArgs){
> /* not enough arguments */
> $errMsg = "not enough arguements supplied, please supply
> database and table name";
> return($errMsg);
> } else {
> /*
> * Supply default values for optional arguements if they
> are not set.
> * An interesting note here: the action can be anything
> that the user
> * specifies, it is not strictly limited to CRUD and it
> will be output
> * in a hidden form field;
> * <input type="hidden" name="action" value="whatever
> action is called">
> * That way when the user clicks 'Submit' the programmer
> can have a
> * switch action in his or her processing script to
> handle this form.
> */
> if(!isset($action)) { $action = 'read'; }
> if(!isset($recordID)) { $recordID = ''; }
> if(!isset($excludeCols)){
> $excludeCols = '';
> } else {
> /* create an array of excluded columns */
> $arrExcludeCols = explode(",", $excludeCols);
> }
>
> /* describe the table */
> $sqlDesc = "DESCRIBE `".$database."`.`".$table."` ";
> if(!($dbInfo = mysql_query($sqlDesc, $dc))){
> return mysql_error();
> } else {
> while($tableInfo = mysql_fetch_array($dbInfo)){
> /*
> * regular expression - we need the data
> that exists between the
> * parentheses in the Type column of the
> database being described
> * so that we can use for length values
> of form fields
> */
> if(!(in_array($tableInfo['Field'],
> $arrExcludeCols))){
> if(preg_match (
> "/\((\d{1,}.*?)\)/", $tableInfo[1], $regs )){
> /* handle numerical
> values in parentheses to create form element lengths */
> echo
> "<label>".$tableInfo['Field']."</label>";
> echo "<input
> type=\"text\" name=\"".$tableInfo['Field']."\" size=\"".$regs[1]."\"
> maxlength=\"".$regs[1]."\"><br />\n";
> } elseif("text" ==
> $tableInfo[1]) {
> /* handle text columns
> */
> echo
> "<label>".$tableInfo['Field']."</label>";
> echo "<textarea
> name=\"".$tableInfo['Field']."\" cols=\"80\" rows=\"10\"></textarea><br
> />\n";
> } elseif("enum" ==
> substr($tableInfo[1], 0, 4)){
> /* handle enumerated
> columns and creat drop downs */
> echo
> "<label>".$tableInfo['Field']."</label>&nbsp;";
> /*
> * regular expression -
> we need the data that
> * exists between the
> single quotes in the Type column of the
> * database being
> described so that we can use for option
> * values in a drop-down
> on the form
> */
> preg_match_all(
> "/'(.*)'/U", $tableInfo[1], $matches);
> echo "<select
> name=\"".$tableInfo['Field']."\">\n";
> echo
> "<option></option>\n";
> for($i = 0; $i <
> count($matches[1]); $i++){
> echo
> "<option>".$matches[1][$i]."</option>\n";
> }
> echo "</select><br
> />\n";
> }//end if preg
> }//end if in_array
> }//end while tableInfo
> /* set up the hidden action field */
> echo "<input type=\"hidden\" name=\"action\"
> value=\"".$action."\">\n";
> /* provide a submit and reset button */
> echo "<input type=\"submit\" name=\"submit\"
> value=\"Submit\">&nbsp;&nbsp;";
> echo "<input type=\"reset\" name=\"reset\"
> value=\"Clear\"><br />\n";
> return;
> }// end if dbInfo
> }// end if numArgs
> }//end function formCreate
>
> With this I need one function call to create the form on the page. I can
> exclude columns and set an action to be taken once the form is filled
> out.
>
> There are several other functions and what I end up with is a set of
> functions that do make up a form handling framework. This can also be
> done in the context of OOP, I just want to show some procedural code.
> This assumes MySQL as the database.
>
> Let the laughter begin.....

I can't say I've ever had a form that exactly matched a database table
for a user perspective. From an admin perspective that changes, but that
was when I downloaded PHPMyAdmin for the client. It was amazing, every
form matched the database table and you could view all the rows too, and
even create your own queries.

Table discovery is something I use for marshalling data back and forth
from database tables, but not usually for presenting a user form.

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

attached mail follows:


>With this I need one function call to create the form on the page. I can
>exclude columns and set an action to be taken once the form is filled
>out.

this work for general form. but when i need to make more complicated form -
with
AJAX to look up for username (available or not). Then the class became more
and
more complicated and it is easier to work on the basic one - embedded HTML.

attached mail follows:


On Fri, Apr 25, 2008 at 10:59 AM, Robert Cummings <robertinterjinn.com>
wrote:

> On Fri, 2008-04-25 at 11:17 -0500, Jay Blanchard wrote:
> > I did a quick and dirty of just one of those functions. This function
> > takes a table and creates a form based on the table. It needs quite a
> > bit of refining, but I am willing to share and let you guys and gals
> > throw suggestions;
> >
> > function formCreate($database, $table, $action, $excludeCols,
> > $recordID){
> > /*
> > * This function is used to create forms on the fly based on
> > tables within
> > * the database. The minimal arguments are database name and
> > table name.
> > * Additional arguements may be supplied to indicate columns to
> > be excluded
> > * from form and an action (CRUD) to be performed once the form
> > * is filled out. If wanting to do an update, read or delete you
> > can specify
> > * a record to retrieve to populate the form. Default values
> > will be provided
> > * for arguements not included.
> > */
> > /* database connection in global variable */
> > global $dc;
> > /* number of arguements sent to function */
> > $numArgs = func_num_args();
> > /* test to make sure that you have the minial two arguements */
> > if(2 > $numArgs){
> > /* not enough arguments */
> > $errMsg = "not enough arguements supplied, please supply
> > database and table name";
> > return($errMsg);
> > } else {
> > /*
> > * Supply default values for optional arguements if they
> > are not set.
> > * An interesting note here: the action can be anything
> > that the user
> > * specifies, it is not strictly limited to CRUD and it
> > will be output
> > * in a hidden form field;
> > * <input type="hidden" name="action" value="whatever
> > action is called">
> > * That way when the user clicks 'Submit' the programmer
> > can have a
> > * switch action in his or her processing script to
> > handle this form.
> > */
> > if(!isset($action)) { $action = 'read'; }
> > if(!isset($recordID)) { $recordID = ''; }
> > if(!isset($excludeCols)){
> > $excludeCols = '';
> > } else {
> > /* create an array of excluded columns */
> > $arrExcludeCols = explode(",", $excludeCols);
> > }
> >
> > /* describe the table */
> > $sqlDesc = "DESCRIBE `".$database."`.`".$table."` ";
> > if(!($dbInfo = mysql_query($sqlDesc, $dc))){
> > return mysql_error();
> > } else {
> > while($tableInfo = mysql_fetch_array($dbInfo)){
> > /*
> > * regular expression - we need the data
> > that exists between the