Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Tommy Pham
On Tue, Feb 7, 2012 at 2:31 PM, Paul M Foster  wrote:
> On Tue, Feb 07, 2012 at 09:02:00PM +, Tim Streater wrote:
>
>> On 07 Feb 2012 at 19:34, Daniel Brown  wrote:
>>
>> > On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
>> >  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
>>
>
> Design Patterns are Way Nifty Kewl patterns of code which are supposed
> to facilitate certain types of operations. (Was that sarcasm you
> detected? Yes it was.)
>
> For example, the Singleton pattern. Let's say you had a configuration
> class that held the configuration values for your application, and you
> wanted to make sure there was only one object of that class
> instantiated, no matter how many times it was called in your code. You'd
> arrange the code and call the class in a certain way to ensure that only
> one object of that class resulted. To make your configuration class a
> "singleton", you'd probably make the class have a *private* constructor
> (so no outside routine could call it), and then provide a method called
> get_instance() which tested for the existence of an object of that
> class. If such an instance was found, someone calling
> configuration::get_instance() would simply get the existing object
> returned to them. Otherwise, configuration::get_instance() would
> instantiate the class and then return the new object to the caller.
>
> As you can see, that's a peculiar way of setting up your code for a
> specific purpose. Other design patterns do other things and dictate
> setting up things in other ways.
>

Here's a code example of the above explanation:

http://pastebin.com/mTrybi6u

HTH,
Tommy


> The definitive work on this (and where it first gained the most
> publicity) is a book called "Design Patterns" by four authors (Gamma,
> Helm, Johnson and Vlissides). It essentially contains a chapter about
> each (known at the time) design pattern and some pseudocode about how it
> might be constructed. I imagine the authors looked at a lot of code and
> discovered that programmers were coming up with code that, in each case
> was remarkably similar for solving certain types of programming
> problems. So they codified what that found and wrote a book about it.
>
> I have the book on my shelf, and it's decent technology, but you could
> spend your whole career and never use any of it, and get along just
> fine.
>
> Paul
>
> --
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Ghodmode
On Wed, Feb 8, 2012 at 4:10 AM, Ashley Sheridan
 wrote:
> 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?
...
> It's fine in PHP, and some coding practices actually encourage it, for
> example:
...
>
> 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.

I believe this behavior was inherited from Perl.  I used Perl before I
used PHP and it was considered a feature for exactly the reason Ash
gave.

I think that problems with Perl may have originally inspired the
creation of PHP, at least in part.  But they kept the good parts.
This is just my perception.  To confirm it, I'd have to ask our BDFL
:)

--
Vince Aggrippino
a.k.a. Ghodmode
http://www.ghodmode.com


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

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



RES: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Alejandro Michelin Salomon
Mike:

My favorite are singleton ( database connection configuration ), and
factory.

Factory i use when need one code exporting or doing different process. 

Basically y have a base class with general code and a specific class that
extend the base class with code specific to the process to be made.
The main code only pass the type of format ant factory returns de right code
for the operation.

The main code remains untouched, when the factory chance each time a i need
other type of process or exportation results.

Alejandro M.S.

-Mensagem original-
De: Mike Mackintosh [mailto:mike.mackint...@angrystatic.com] 
Enviada em: terça-feira, 7 de fevereiro de 2012 16:57
Para: PHP General List
Assunto: [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





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



Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Paul M Foster
On Tue, Feb 07, 2012 at 09:02:00PM +, Tim Streater wrote:

> On 07 Feb 2012 at 19:34, Daniel Brown  wrote: 
> 
> > On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
> >  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
> 

Design Patterns are Way Nifty Kewl patterns of code which are supposed
to facilitate certain types of operations. (Was that sarcasm you
detected? Yes it was.)

For example, the Singleton pattern. Let's say you had a configuration
class that held the configuration values for your application, and you
wanted to make sure there was only one object of that class
instantiated, no matter how many times it was called in your code. You'd
arrange the code and call the class in a certain way to ensure that only
one object of that class resulted. To make your configuration class a
"singleton", you'd probably make the class have a *private* constructor
(so no outside routine could call it), and then provide a method called
get_instance() which tested for the existence of an object of that
class. If such an instance was found, someone calling
configuration::get_instance() would simply get the existing object
returned to them. Otherwise, configuration::get_instance() would
instantiate the class and then return the new object to the caller.

As you can see, that's a peculiar way of setting up your code for a
specific purpose. Other design patterns do other things and dictate
setting up things in other ways.

The definitive work on this (and where it first gained the most
publicity) is a book called "Design Patterns" by four authors (Gamma,
Helm, Johnson and Vlissides). It essentially contains a chapter about
each (known at the time) design pattern and some pseudocode about how it
might be constructed. I imagine the authors looked at a lot of code and
discovered that programmers were coming up with code that, in each case
was remarkably similar for solving certain types of programming
problems. So they codified what that found and wrote a book about it.

I have the book on my shelf, and it's decent technology, but you could
spend your whole career and never use any of it, and get along just
fine. 

Paul

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

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



Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Tim Streater
On 07 Feb 2012 at 19:34, Daniel Brown  wrote: 

> On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
>  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

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

Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Micky Hulse
On Tue, Feb 7, 2012 at 12:32 PM, Ashley Sheridan
 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

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Ashley Sheridan
On Tue, 2012-02-07 at 12:26 -0800, Micky Hulse wrote:

> On Tue, Feb 7, 2012 at 12:19 PM, Micky Hulse  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




Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Robert Williams
On 2/7/12 13:15, "Paul M Foster"  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:



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).

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



Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Bastien

On 2012-02-07, at 2:34 PM, Daniel Brown  wrote:

> On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
>  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.
> 
> -- 
> 
> 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Micky Hulse
On Tue, Feb 7, 2012 at 12:19 PM, Micky Hulse  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

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Micky Hulse
On Tue, Feb 7, 2012 at 12:15 PM, Paul M Foster  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

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Ashley Sheridan
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:
> > 
> > 
> > 
> > ... 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




Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Micky Hulse
Hi Ashley! Thanks for your quick and informative reply, I really
appreciate it. :)

On Tue, Feb 7, 2012 at 12:10 PM, Ashley Sheridan
 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

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Paul M Foster
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:
> 
> 
> 
> ... 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

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



Re: [PHP] Arrays: Comma at end?

2012-02-07 Thread Ashley Sheridan
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:
> 
> 
> 
> ... 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




[PHP] Arrays: Comma at end?

2012-02-07 Thread Micky Hulse
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:



... 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

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



Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Daniel Brown
On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
 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.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Fatih P.
mostly MVC, Singleton and Factory. depends on requirements.


Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Adam Richardson
On Tue, Feb 7, 2012 at 1:56 PM, Mike Mackintosh <
mike.mackint...@angrystatic.com> 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


RE: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread admin
> -Original Message-
> From: Mike Mackintosh [mailto:mike.mackint...@angrystatic.com]
> 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.


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



Re: [PHP] How to detect languages from (=> LTR vs RTL)

2012-02-07 Thread Dotan Cohen
On Tue, Feb 7, 2012 at 19:31, Dotan Cohen  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

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



Re: [PHP] How to detect languages from (=> LTR vs RTL)

2012-02-07 Thread Dotan Cohen
On Tue, Feb 7, 2012 at 10:37, 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
>
>    
>      $SOME_TEXT
>    
>
> 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

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



Re: [PHP] Long Live GOTO

2012-02-07 Thread Tedd Sperling
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

_
t...@sperling.com
http://sperling.com

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



Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Tedd Sperling
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


_
t...@sperling.com
http://sperling.com



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



RE: [PHP] syntax question

2012-02-07 Thread admin

> -Original Message-
> From: ma...@behnke.biz [mailto:ma...@behnke.biz]
> Sent: Tuesday, February 07, 2012 10:47 AM
> To: php-general@lists.php.net; ad...@buskirkgraphics.com
> Subject: Re: [PHP] syntax question
> 
> 
> 
> ad...@buskirkgraphics.com 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: ma...@behnke.biz
> 
> 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.
 



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



Re: [PHP] syntax question

2012-02-07 Thread ma...@behnke.biz


ad...@buskirkgraphics.com 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: ma...@behnke.biz

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

http://www.behnke.biz

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



Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Marc Guay
> 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

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



RE: [PHP] syntax question

2012-02-07 Thread admin

> -Original Message-
> From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com]
> Sent: Tuesday, February 07, 2012 9:24 AM
> To: ad...@buskirkgraphics.com
> Cc: php-general@lists.php.net
> 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 
> 
> > 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`)




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



Re: [PHP] syntax question

2012-02-07 Thread Louis Huppenbauer
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 

> 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 .
>
>
>
>
>
>
>
>
>
>


[PHP] syntax question

2012-02-07 Thread admin
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 .

 

 

 

 



Re: [PHP] Re: How can I debug wsf/php in eclipse?

2012-02-07 Thread Ali Asghar Toraby Parizy
:(
Thanks for your help. Is it the only way?

On Tue, Feb 7, 2012 at 12:44 PM, Sharl.Jimh.Tsin 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 <
> > aliasghar.tor...@gmail.com> 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.
>


Re: [PHP] How to detect languages from (=> LTR vs RTL)

2012-02-07 Thread Ashley Sheridan
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
> 
> 
>   $SOME_TEXT
> 
> 
> 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




Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Ashley Sheridan
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




Re: [PHP] Re: How can I debug wsf/php in eclipse?

2012-02-07 Thread Sharl.Jimh.Tsin
在 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 <
> aliasghar.tor...@gmail.com> 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.


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


[PHP] Re: How can I debug wsf/php in eclipse?

2012-02-07 Thread Ali Asghar Toraby Parizy
Can anybody help me in this regard?

On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy <
aliasghar.tor...@gmail.com> 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.
>


[PHP] How to detect languages from (=> LTR vs RTL)

2012-02-07 Thread Michelle Konzack
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


  $SOME_TEXT


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

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux
   Internet Service Provider, Cloud Computing


itsystems@tdnet Jabber  linux4miche...@jabber.ccc.de
Owner Michelle Konzack

Gewerbe Strasse 3   Tel office: +49-176-86004575
77694 Kehl  Tel mobil:  +49-177-9351947
Germany Tel mobil:  +33-6-61925193  (France)

USt-ID:  DE 278 049 239

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature