php-general Digest 7 Feb 2012 21:02:38 -0000 Issue 7679

Topics (messages 316516 through 316548):

Re: How can I debug wsf/php in eclipse?
        316516 by: Ali Asghar Toraby Parizy
        316517 by: Sharl.Jimh.Tsin
        316520 by: Ali Asghar Toraby Parizy
        316521 by: marco.behnke.biz

Re: Headers on smart phone browsers
        316518 by: Ashley Sheridan
        316525 by: Marc Guay
        316528 by: Tedd Sperling

Re: How to detect languages from (=> LTR vs RTL)
        316519 by: Ashley Sheridan
        316530 by: Dotan Cohen
        316531 by: Dotan Cohen

syntax question
        316522 by: admin.buskirkgraphics.com
        316523 by: Louis Huppenbauer
        316524 by: admin.buskirkgraphics.com
        316526 by: marco.behnke.biz
        316527 by: admin.buskirkgraphics.com

Re: Long Live GOTO
        316529 by: Tedd Sperling

What's Your Favorite Design Pattern?
        316532 by: Mike Mackintosh
        316533 by: admin.buskirkgraphics.com
        316534 by: Adam Richardson
        316535 by: Fatih P.
        316536 by: Daniel Brown
        316544 by: Bastien
        316548 by: Tim Streater

Arrays: Comma at end?
        316537 by: Micky Hulse
        316538 by: Ashley Sheridan
        316539 by: Paul M Foster
        316540 by: Micky Hulse
        316541 by: Ashley Sheridan
        316542 by: Micky Hulse
        316543 by: Micky Hulse
        316545 by: Robert Williams
        316546 by: Ashley Sheridan
        316547 by: Micky Hulse

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 ---
Can anybody help me in this regard?

On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy <
[email protected]> wrote:

> Hi.
> I'm developing a wsf/php web service. I'm using doc/lit messaging format
> and every thing is OK.
> But I don't know how i can debug my web services using eclipse.
> Although I can directly run my web service in debug mode, Unfortunately
> when I debug my client it never jump into web service code and I only can
> see if that service has returned a correct value or not!
> I'd be glad to know if it's possible or not to do something like this in
> eclipse.
> Thanks for any help.
>

--- End Message ---
--- Begin Message ---
在 2012-02-07二的 12:11 +0330,Ali Asghar Toraby Parizy写道:
> Can anybody help me in this regard?
> 
> On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy <
> [email protected]> wrote:
> 
> > Hi.
> > I'm developing a wsf/php web service. I'm using doc/lit messaging format
> > and every thing is OK.
> > But I don't know how i can debug my web services using eclipse.
> > Although I can directly run my web service in debug mode, Unfortunately
> > when I debug my client it never jump into web service code
print the log to console or something else.
>  and I only can
> > see if that service has returned a correct value or not!
> > I'd be glad to know if it's possible or not to do something like this in
> > eclipse.
> > Thanks for any help.
> >

-- 
Best regards,
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**)

Using Gmail? Please read this important notice:
http://www.fsf.org/campaigns/jstrap/gmail?10073.

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---
--- Begin Message ---
:(
Thanks for your help. Is it the only way?

On Tue, Feb 7, 2012 at 12:44 PM, Sharl.Jimh.Tsin <[email protected]>wrote:

> 在 2012-02-07二的 12:11 +0330,Ali Asghar Toraby Parizy写道:
> > Can anybody help me in this regard?
> >
> > On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy <
> > [email protected]> wrote:
> >
> > > Hi.
> > > I'm developing a wsf/php web service. I'm using doc/lit messaging
> format
> > > and every thing is OK.
> > > But I don't know how i can debug my web services using eclipse.
> > > Although I can directly run my web service in debug mode, Unfortunately
> > > when I debug my client it never jump into web service code
> print the log to console or something else.
> >  and I only can
> > > see if that service has returned a correct value or not!
> > > I'd be glad to know if it's possible or not to do something like this
> in
> > > eclipse.
> > > Thanks for any help.
> > >
>
> --
> Best regards,
> Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**)
>
> Using Gmail? Please read this important notice:
> http://www.fsf.org/campaigns/jstrap/gmail?10073.
>

--- End Message ---
--- Begin Message ---


Ali Asghar Toraby Parizy <[email protected]> hat am 6. Februar
2012 um 19:45 geschrieben:

> Hi.
> I'm developing a wsf/php web service. I'm using doc/lit messaging format
> and every thing is OK.
> But I don't know how i can debug my web services using eclipse.
> Although I can directly run my web service in debug mode, Unfortunately
> when I debug my client it never jump into web service code and I only can
> see if that service has returned a correct value or not!
> I'd be glad to know if it's possible or not to do something like this in
> eclipse.

Ii knew there where issues in the past with eclipse and I am not sure if
they are done yet but you can instead download Zend Studio (which is
eclipse) and use the xdebug extension for remote debugging on your apache.

I am not quite sure if the Zend Server CE has debugging facilities but Zend
Server together with Zend Studio is in my opinion the best debugging
partnership.

You can set break points and all that stuff.

Another way is using dtrace but I am not quite sure what you can exactly do
with that.

> Thanks for any help.
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: [email protected]

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: [email protected]

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---
--- Begin Message ---
On Mon, 2012-02-06 at 18:09 -0600, Donovan Brooke wrote:

> Mari Masuda wrote:
> [snip]
> > For a concrete example of responsive design in action, point your browser 
> > to http://www.sasquatchfestival.com/ and then slowly make the window 
> > wider/skinnier to see how the design adapts to different viewport sizes.
> 
> 
> Very nice... makes for an easy display to a wide range of circumstances 
> I think.. especially image resizing (in the blog example), which looks 
> pretty smooth. But, in both the examples, it appears it can produce a 
> "choppy" user experience when resizing the window as well...
> 
> I suppose that resizing could be viewed as one of those 80/20 percent 
> rule things.. meaning, window resizing is probably not a prevalent 
> action for a user and it could be argued that one shouldn't code a site 
> worrying too much about dynamic window resizing... but then there is a 
> form of resizing, which is turning your iPAD to landscape view, etc..
> 
> I suppose one could probably still do some UA detection and serve up 
> content based on the "type" of UA (ie. mobile, IE, game-based) and at 
> that point, still incorporate responsive web design, but to that 
> more-limited-category of UA's.
> 
> Donovan
> 
> 
> 
> 
> 
> -- 
> D Brooke
> 


There is only one drawback to using CSS media queries to alter the way a
page is displayed on different resolutions, and that is that any media
(i.e. background images, etc) referenced in a stylesheet is downloaded,
regardless of if it is ever used.

So if you have two background images for the body, one large for nice
wide screens, and a smaller one for smaller screens, they will both be
downloaded by the browser. The way around this is to use Javascript to
load only the stylesheets required, but then you're relying on
Javascript and you don't need media queries. It's a pain finding the
right balance.

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



--- End Message ---
--- Begin Message ---
> There is only one drawback to using CSS media queries to alter the way a
> page is displayed on different resolutions, and that is that any media
> (i.e. background images, etc) referenced in a stylesheet is downloaded,
> regardless of if it is ever used.

Another one worth mentionning is that a lot of mobile devices still in
use do not support media queries - their being a relatively recent
development.  Same goes for javascript, even if it claims to support
it.  Older Blackberrys claim JS support but fail miserably in real
life.

Marc

--- End Message ---
--- Begin Message ---
On Feb 6, 2012, at 4:01 PM, Stuart Dallas wrote:
> Generally speaking you're better off with a design that automatically adapts 
> to the viewport on which it's being displayed. While there's more than one 
> reason for this, the overriding reason is that the same software (i.e. the 
> same user agent) could be running on any size of device, from watch to huge 
> flat panel screen on a wall.
> 
> I think the world needs to move on from "is it a mobile device or not" to 
> accepting the reality which is that the browser / OS is irrelevant, and that 
> the way your site renders should be purely based upon the size of the 
> display. Responsive designs such as that described in the A List Apart 
> article Mari posted are fantastic tools for achieving this goal.
> 
> -Stuart
> 

Agreed. Not only the size of the display -- but what's a size of a pixel?

http://www.alistapart.com/articles/a-pixel-identity-crisis/

Presentation is a difficult problem to solve, but I don't think PHP enters into 
the equation. From my view, the only thing that PHP can do is device-sniff, 
which is clearly a losing proposition.

I believe that a presentation solution will be solved by presentation languages 
(i.e, client-side).

Cheers,

tedd


_____________________
[email protected]
http://sperling.com



--- End Message ---
--- Begin Message ---
On Tue, 2012-02-07 at 09:37 +0100, Michelle Konzack wrote:

> Hi colleges and gurus,
> 
> I coding a whole "web office" and one of my problems is "LTR vs RTL".
> If I have for exanple an E-Mail I use a
> 
>     <div style="direction:$DIRECTION">
>       $SOME_TEXT
>     </div>
> 
> but HOW can I detect the type of $SOME_TEXT  from  within  PHP,  to  set
> $DIRECTION? (RTL or LTR) correctly?
> 
> And how can I do this with mixed Text (by  line  or  entired  paragraph)
> like:
> 
>    german       <- must be LTR
>    persian      <------------------- must be RTL
>    english      <- must be LTR
>    arabic       <------------------- must be RTL
>    french       <- must be LTR
>    jidisch      <------------------- must be RTL
> 
> Ayn Iranian (Moxhtar?), Arabs (Jasin?) or Jews (Dotan?) here  which  can
> help me please?
> 
> Thanks, Greetings and nice Day/Evening
>     Michelle Konzack
> 


If I understand you correctly, you want to detect the language of a
string, or is it a substring within a string?

I'm not sure how easy that would be, given that some shorter sentences
might be common across languages, but I would hazard a guess that they
would also share the direction, so that shouldn't be a major issue.

I don't know of any way to do that, but could you possibly look for
certain characters in the string that would hint at the language? It
wouldn't work too well with mixed-language strings, but it might be
enough for what you want here?

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



--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 10:37, Michelle Konzack
<[email protected]> wrote:
> Hi colleges and gurus,
>
> I coding a whole "web office" and one of my problems is "LTR vs RTL".
> If I have for exanple an E-Mail I use a
>
>    <div style="direction:$DIRECTION">
>      $SOME_TEXT
>    </div>
>
> but HOW can I detect the type of $SOME_TEXT  from  within  PHP,  to  set
> $DIRECTION? (RTL or LTR) correctly?
>
> And how can I do this with mixed Text (by  line  or  entired  paragraph)
> like:
>
>   german       <- must be LTR
>   persian      <------------------- must be RTL
>   english      <- must be LTR
>   arabic       <------------------- must be RTL
>   french       <- must be LTR
>   jidisch      <------------------- must be RTL
>
> Ayn Iranian (Moxhtar?), Arabs (Jasin?) or Jews (Dotan?) here  which  can
> help me please?
>
> Thanks, Greetings and nice Day/Evening
>    Michelle Konzack
>

Hi Michelle! There is no reliable way to determine the intent of the
author, but most software detects RTL vs LTR by the first "strong"
character found in the string. Strong characters are letters, not
punctuation or numbers which are used in both LTR or RTL environments.

Untested, but you might be able to do something like this:

while (!feof($input)) {
    $char = fgetc($input);
    if ( is_strong($char) ) {
        $direction=is_strong($char);
        break;
    }
}

function is_strong($char) {
    if (  in_array($char, $arrayOfRtlCharacters)  ) {
        return "RTL";
    }
    if (  in_array($char, $arrayOfLtrCharacters)  ) {
        return "LTR";
    }
    return FALSE;
}

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 19:31, Dotan Cohen <[email protected]> wrote:
> function is_strong($char) {
>    if (  in_array($char, $arrayOfRtlCharacters)  ) {
>        return "RTL";
>    }
>    if (  in_array($char, $arrayOfLtrCharacters)  ) {
>        return "LTR";
>    }
>    return FALSE;
> }
>

On second thought, you might want to try preg_match() instead of
in_array() to use character ranges.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--- End Message ---
--- Begin Message ---
I have been struggling with this issue for an hour and honestly I am not
sure why.

I consider myself to be pretty savvy with MySQL but I am running into an
syntax error that is just flat out eluding me.

 

$query = "SELECT `table2`.`name` from `table1` ,`table2` WHERE
`table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1";

This query works!!

 

But If I try to add a GROUP BY to the query, complete failure.

$query = "SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
`table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY `table1`.`ID`
LIMIT 1";

 

The main goal here is to get only 1 return but MySQL is returning the same
row 2 times.

Before I beat my head in anymore I will toss this out to you guys and beat
myself up later for not drinking enough coffee or something .

 

 

 

 


--- End Message ---
--- Begin Message ---
Generally... Wouldn't grouping by an id (which is normally unique) have no
real benefit... Except some strange behaviour?

Just to clarify: Why aren't you sticking to the LIMIT 1?

2012/2/7 <[email protected]>

> I have been struggling with this issue for an hour and honestly I am not
> sure why.
>
> I consider myself to be pretty savvy with MySQL but I am running into an
> syntax error that is just flat out eluding me.
>
>
>
> $query = "SELECT `table2`.`name` from `table1` ,`table2` WHERE
> `table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
> Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1";
>
> This query works!!
>
>
>
> But If I try to add a GROUP BY to the query, complete failure.
>
> $query = "SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
> `table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
> Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY `table1`.`ID`
> LIMIT 1";
>
>
>
> The main goal here is to get only 1 return but MySQL is returning the same
> row 2 times.
>
> Before I beat my head in anymore I will toss this out to you guys and beat
> myself up later for not drinking enough coffee or something .
>
>
>
>
>
>
>
>
>
>

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Louis Huppenbauer [mailto:[email protected]]
> Sent: Tuesday, February 07, 2012 9:24 AM
> To: [email protected]
> Cc: [email protected]
> Subject: Re: [PHP] syntax question
> 
> Generally... Wouldn't grouping by an id (which is normally unique) have
> no
> real benefit... Except some strange behaviour?
> 
> Just to clarify: Why aren't you sticking to the LIMIT 1?
> 
> 2012/2/7 <[email protected]>
> 
> > I have been struggling with this issue for an hour and honestly I am
> not
> > sure why.
> >
> > I consider myself to be pretty savvy with MySQL but I am running into
> an
> > syntax error that is just flat out eluding me.
> >
> >
> >
> > $query = "SELECT `table2`.`name` from `table1` ,`table2` WHERE
> > `table2`.`user_id`=`table1`.`seller_id` AND
> IF(`table2`.`name`='juice','No
> > Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1";
> >
> > This query works!!
> >
> >
> >
> > But If I try to add a GROUP BY to the query, complete failure.
> >
> > $query = "SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
> > `table2`.`user_id`=`table1`.`seller_id` AND
> IF(`table2`.`name`='juice','No
> > Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY
> `table1`.`ID`
> > LIMIT 1";
> >
> >
> >
> > The main goal here is to get only 1 return but MySQL is returning the
> same
> > row 2 times.
> >
> > Before I beat my head in anymore I will toss this out to you guys and
> beat
> > myself up later for not drinking enough coffee or something .
> >
> >



There is no real reason to have a LIMIT It was just yet another attempt to 
limit the results during the testing.
After reading my post back I see an error in the IF statement but not the 
resolution to the issue.

The IF should read
IF(`table2`.`name`='juice',`table2`.`name`=`table1`.`code`, 
`table2`.`name`=`table1`.`ref`)




--- End Message ---
--- Begin Message ---

[email protected] hat am 7. Februar 2012 um 15:11 geschrieben:

> I have been struggling with this issue for an hour and honestly I am not
> sure why.
>
> I consider myself to be pretty savvy with MySQL but I am running into an
> syntax error that is just flat out eluding me.
>
> 
>
> $query = "SELECT `table2`.`name` from `table1` ,`table2` WHERE
> `table2`.`user_id`=`table1`.`seller_id` AND
IF(`table2`.`name`='juice','No
> Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1";
>
> This query works!!
>
> 
>
> But If I try to add a GROUP BY to the query, complete failure.
>
> $query = "SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
> `table2`.`user_id`=`table1`.`seller_id` AND
IF(`table2`.`name`='juice','No
> Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY `table1`.`ID`
> LIMIT 1";


This is a nice query but I am not sure if I understand what you want to do?
Maybe we could start with your error message and a table structure :-) That
would be handy.

You wanna get all users that have at least on sell? But only once?

Maybe something like that?

SELECT table2.name
FROM
  table2,
  (SELECT seller_id FROM table1 GROUP BY seller_id) as table1
WHERE
  table2.user_id = table1.seller_id
  AND IF(table2.name = 'juice','No Juice for YOU', table2.name =
table2.name)
;




Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: [email protected]

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Tuesday, February 07, 2012 10:47 AM
> To: [email protected]; [email protected]
> Subject: Re: [PHP] syntax question
> 
> 
> 
> [email protected] hat am 7. Februar 2012 um 15:11 geschrieben:
> 
> > I have been struggling with this issue for an hour and honestly I am
> not
> > sure why.
> >
> > I consider myself to be pretty savvy with MySQL but I am running into
> an
> > syntax error that is just flat out eluding me.
> >
> >
> >
> > $query = "SELECT `table2`.`name` from `table1` ,`table2` WHERE
> > `table2`.`user_id`=`table1`.`seller_id` AND
> IF(`table2`.`name`='juice','No
> > Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1";
> >
> > This query works!!
> >
> >
> >
> > But If I try to add a GROUP BY to the query, complete failure.
> >
> > $query = "SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
> > `table2`.`user_id`=`table1`.`seller_id` AND
> IF(`table2`.`name`='juice','No
> > Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY
> `table1`.`ID`
> > LIMIT 1";
> 
> 
> This is a nice query but I am not sure if I understand what you want to
> do?
> Maybe we could start with your error message and a table structure :-)
> That
> would be handy.
> 
> You wanna get all users that have at least on sell? But only once?
> 
> Maybe something like that?
> 
> SELECT table2.name
> FROM
>   table2,
>   (SELECT seller_id FROM table1 GROUP BY seller_id) as table1
> WHERE
>   table2.user_id = table1.seller_id
>   AND IF(table2.name = 'juice','No Juice for YOU', table2.name =
> table2.name)
> ;
> 
> 
> 
> 
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
> 
> Tel.: 0174 / 9722336
> e-Mail: [email protected]
> 
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
> 
> http://www.behnke.biz



Marco,
        Thank you but the whole issue stemed from the 2nd table in the FROM.
I just did an inner join using the If statement and it resolved the whole issue.
Maybe it was just a coffee thing because 2 cups later I seen it very clearly :)

Thanks so much.
 



--- End Message ---
--- Begin Message ---
On Feb 6, 2012, at 11:28 AM, Larry Martell wrote:
> Just for another data point, the FAA does not allow gotos in any code
> that goes into an airplane.

That settles it -- the government knows best.

Cheers,

tedd

_____________________
[email protected]
http://sperling.com

--- End Message ---
--- Begin Message ---
I was curious to see what everyones favorite design patterns were, if you use 
any, and why/when have you used it?

Choices include slots and signals (observer), singleton, mvc, hmvc, factory, 
commander etc..

Thanks,

--
Mike Mackintosh
PHP, the drug of choice - www.highonphp.com




--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Mike Mackintosh [mailto:[email protected]]
> Sent: Tuesday, February 07, 2012 1:57 PM
> To: PHP General List
> Subject: [PHP] What's Your Favorite Design Pattern?
> 
> I was curious to see what everyones favorite design patterns were, if
> you use any, and why/when have you used it?
> 
> Choices include slots and signals (observer), singleton, mvc, hmvc,
> factory, commander etc..
> 
> Thanks,
> 
> --
> Mike Mackintosh
> PHP, the drug of choice - www.highonphp.com
> 
> 


MVC because it allows the most flexibility and I use it every day.


--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 1:56 PM, Mike Mackintosh <
[email protected]> wrote:

> I was curious to see what everyones favorite design patterns were, if you
> use any, and why/when have you used it?
>
> Choices include slots and signals (observer), singleton, mvc, hmvc,
> factory, commander etc..


Higher-order functions:

http://programmers.stackexchange.com/questions/72557/how-do-you-design-programs-in-haskell-or-other-functional-programming-languages

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
mostly MVC, Singleton and Factory. depends on requirements.

--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
<[email protected]> wrote:
> I was curious to see what everyones favorite design patterns were, if you use 
> any, and why/when have you used it?
>
> Choices include slots and signals (observer), singleton, mvc, hmvc, factory, 
> commander etc..

    Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit),
as that's what I encounter no less than 80% of the time in the wild.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On 2012-02-07, at 2:34 PM, Daniel Brown <[email protected]> wrote:

> On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
> <[email protected]> wrote:
>> I was curious to see what everyones favorite design patterns were, if you 
>> use any, and why/when have you used it?
>> 
>> Choices include slots and signals (observer), singleton, mvc, hmvc, factory, 
>> commander etc..
> 
>    Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit),
> as that's what I encounter no less than 80% of the time in the wild.
> 
> -- 
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

I think you should trademark that, Dan 

Bastien Koert

--- End Message ---
--- Begin Message ---
On 07 Feb 2012 at 19:34, Daniel Brown <[email protected]> wrote: 

> On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
> <[email protected]> wrote:
>> I was curious to see what everyones favorite design patterns were, if you use
>> any, and why/when have you used it?
>>
>> Choices include slots and signals (observer), singleton, mvc, hmvc, factory,
>> commander etc..
>
>    Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit),
> as that's what I encounter no less than 80% of the time in the wild.

Since I have no idea what anyone is talking about, I can only conclude that 
you're playing Mornington Crescent (q.v.), on a non-standard board.

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
Was there ever a time when having a comma at the end of the last array
element was not acceptable in PHP?

I just did a few quick tests:

<https://gist.github.com/1761490>

... and it looks like having that comma ain't no big deal.

I can't believe that I always thought that having the trailing comma
was a no-no in PHP (maybe I picked that up from my C++ classes in
college? I just don't remember where I picked up this (bad) habit).

I would prefer to have the trailing comma... I just can't believe I
have avoided using it for all these years.

Thanks!
Micky

--- End Message ---
--- Begin Message ---
On Tue, 2012-02-07 at 11:50 -0800, Micky Hulse wrote:

> Was there ever a time when having a comma at the end of the last array
> element was not acceptable in PHP?
> 
> I just did a few quick tests:
> 
> <https://gist.github.com/1761490>
> 
> ... and it looks like having that comma ain't no big deal.
> 
> I can't believe that I always thought that having the trailing comma
> was a no-no in PHP (maybe I picked that up from my C++ classes in
> college? I just don't remember where I picked up this (bad) habit).
> 
> I would prefer to have the trailing comma... I just can't believe I
> have avoided using it for all these years.
> 
> Thanks!
> Micky
> 


It's fine in PHP, and some coding practices actually encourage it, for
example:

$var = array(
    'element',
    'element',
    'element',
);

It's easy to add and remove elements without making sure you have to
check the trailing comma. It's also OK in Javascript to use the trailing
comma, as long as you don't mind things not working on IE, which is the
only browser that has issues with it. As far as PHP goes though, it's
fine.

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



--- End Message ---
--- Begin Message ---
On Tue, Feb 07, 2012 at 11:50:45AM -0800, Micky Hulse wrote:

> Was there ever a time when having a comma at the end of the last array
> element was not acceptable in PHP?
> 
> I just did a few quick tests:
> 
> <https://gist.github.com/1761490>
> 
> ... and it looks like having that comma ain't no big deal.
> 
> I can't believe that I always thought that having the trailing comma
> was a no-no in PHP (maybe I picked that up from my C++ classes in
> college? I just don't remember where I picked up this (bad) habit).
> 
> I would prefer to have the trailing comma... I just can't believe I
> have avoided using it for all these years.
> 
> Thanks!
> Micky

I've always avoided trailing array commas, but only because I was under
the impression that leaving one there would append a blank array member
to the array, where it might be problematic. Yes? No?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--- End Message ---
--- Begin Message ---
Hi Ashley! Thanks for your quick and informative reply, I really
appreciate it. :)

On Tue, Feb 7, 2012 at 12:10 PM, Ashley Sheridan
<[email protected]> wrote:
> It's easy to add and remove elements without making sure you have to check 
> the trailing comma. It's also OK in Javascript to use the trailing comma, as 
> long as you don't mind things not working on IE, which is the only browser 
> that has issues with it. As far as PHP goes though, it's fine.

Makes sense, thanks!

Gosh, I wonder if I picked up this habit due to my JS coding
knowledge? Anyway, thanks for the clarification. :)

Have an awesome day!

Cheers,
Micky

--- End Message ---
--- Begin Message ---
On Tue, 2012-02-07 at 15:15 -0500, Paul M Foster wrote:

> On Tue, Feb 07, 2012 at 11:50:45AM -0800, Micky Hulse wrote:
> 
> > Was there ever a time when having a comma at the end of the last array
> > element was not acceptable in PHP?
> > 
> > I just did a few quick tests:
> > 
> > <https://gist.github.com/1761490>
> > 
> > ... and it looks like having that comma ain't no big deal.
> > 
> > I can't believe that I always thought that having the trailing comma
> > was a no-no in PHP (maybe I picked that up from my C++ classes in
> > college? I just don't remember where I picked up this (bad) habit).
> > 
> > I would prefer to have the trailing comma... I just can't believe I
> > have avoided using it for all these years.
> > 
> > Thanks!
> > Micky
> 
> I've always avoided trailing array commas, but only because I was under
> the impression that leaving one there would append a blank array member
> to the array, where it might be problematic. Yes? No?
> 
> Paul
> 
> -- 
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com
> 


I've never experienced any blank elements in my arrays, maybe that was a
bug that only existed in very specific scenarios?

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



--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 12:15 PM, Paul M Foster <[email protected]> wrote:
> I've always avoided trailing array commas, but only because I was under
> the impression that leaving one there would append a blank array member
> to the array, where it might be problematic. Yes? No?

Yah, ditto! :D

In my few simple tests, using PHP5.x, the last comma is ignored.

Just feels strange to have avoided doing something for so long, only
to learn that it's something I need not worry about! :D

--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 12:19 PM, Micky Hulse <[email protected]> wrote:
> Yah, ditto! :D

$s = 'foo,bar,';
print_r(explode(',', $s));

The output is:

Array
(
    [0] => foo
    [1] => bar
    [2] =>
)

That's one instance where I know you have to be cautious about the
trailing delimiter.

I know, this is all noob stuff... Sorry. :D

--- End Message ---
--- Begin Message ---
On 2/7/12 13:15, "Paul M Foster" <[email protected]> wrote:


>I've always avoided trailing array commas, but only because I was under
>the impression that leaving one there would append a blank array member
>to the array, where it might be problematic. Yes? No?

Nope. In fact, it's officially supported syntax:

<http://us3.php.net/manual/en/function.array.php>

I love it, particularly when used with the already-noted multi-line array
syntax (I don't recommend it with single-line arrangements):

$foo = array(
   1,
   2,
   3,
); //$foo

This makes it dead easy to add, remove, or reorder elements without
worrying about accidentally breaking the syntax. Much like always using
braces around flow-control blocks, this practice makes future bugs less
likely to be born.

Now if only we could have support for trailing commas in SQL UPDATE/INSERT
field and value lists....


Regards,
Bob


--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/





Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--- End Message ---
--- Begin Message ---
On Tue, 2012-02-07 at 12:26 -0800, Micky Hulse wrote:

> On Tue, Feb 7, 2012 at 12:19 PM, Micky Hulse <[email protected]> wrote:
> > Yah, ditto! :D
> 
> $s = 'foo,bar,';
> print_r(explode(',', $s));
> 
> The output is:
> 
> Array
> (
>     [0] => foo
>     [1] => bar
>     [2] =>
> )
> 
> That's one instance where I know you have to be cautious about the
> trailing delimiter.
> 
> I know, this is all noob stuff... Sorry. :D
> 


That's because it's not an array you've got the trailing delimiter on,
it's a string. We were talking about commas on the end of the last
element in the array, like:

$var = array(
    'foo',
    'bar',
);

That only contains two elements, and won't have a hidden 3rd at any
time.

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



--- End Message ---
--- Begin Message ---
On Tue, Feb 7, 2012 at 12:32 PM, Ashley Sheridan
<[email protected]> wrote:
> That's because it's not an array you've got the trailing delimiter on, it's a 
> string.

Right. Sorry, bad example.

it was just the one example I could think of where you could get an
empty element at the end of your array.

Clearly, apples and oranges though.

Thanks!
Micky

--- End Message ---

Reply via email to