Re: a shortcut to set variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday, 12 April 2011 at 11:52, tedd wrote:
At 11:06 AM +0100 4/12/11, Stuart Dallas wrote:
> > On Tuesday, 12 April 2011 at 10:36, Joe Francis wrote:
> > eh, I just want to get a shortcut like
> > > 
> > >  $id = isset($_GET['id']) ? $_GET['id'] : 0;
> > > 
> > > 
> > >  BTW, I'm using PHP5.3+, thanks bros.
> > 
> > http://stut.net/2011/04/12/php-snippet-array-element-access/
> > 
> > -Stuart
> > 
> > --
> > Stuart Dallas
> 
> Stuart:
> 
> Interesting and nice idea (your snippets). I'm sure it's easier for 

I've changed the syntax highlighter I use, so I really need to go back over previous snippets and fix them!

> you to read, but my first thought about V() is huh? In truth, it 
> would take me a while to get used to it and if I came across it in 
> someone else's code I would find it more confusing than a ternary 
> operator.

Then calling it ifsetor would probably work better.

> Questions:
> 
> 1. Why "V"? Does that stand for Variable?

Yup.

> 2. Why the "()" in:
> 
> $var = (isset($_GET['var']) ? $_GET['var']) : '');
> 
> Why not?
> 
> $var = isset($_GET['var']) ? $_GET['var']) : '';

Clarity-based habit. They are in no way necessary.

> 3. Are the "Ramblings of a random software engineer" the "Ramblings 
> of a random-software engineer" or the "Ramblings of a random 
> software-engineer" ?

Take your pick. I'm available for contract work, and a lot of that is random!

:)

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/






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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux