You are here: Re: How about const supporting array in future? « PHP Programming Language « IT news, forums, messages
Re: How about const supporting array in future?

Posted by Yarco on 08/02/07 10:10

Well...Yes....but nothing is better than use const array.

I've already done such things:
$buf = range(0, 12); unset($buf[0]);
array_walk($buf, create_function('&$v, $k', '$v = date("M",
strtotime("2007-$k-01"));'));
print_r($buf);

.......what a pity php doesn't support const array...

On Aug 2, 4:44 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> Yarco wrote:
> > But cause $MONTH_NAMES is variable, someone could change the value.
>
> If you overload the class' __set() function you can effectively make it
> read-only. (Assuming you're using PHP 5.)
>
> Better though:
>
> function get_month_name ($n, $fmt='M')
> {
> $d = mktime(12, 0, 0, $n, 1, 1970);
> return date($fmt, $d);
> }
>
> --
> Toby A Inkster BSc (Hons) ARCS
> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> [OS: Linux 2.6.12-12mdksmp, up 42 days, 12:20.]
>
> PHP Encryption Class
> http://tobyinkster.co.uk/blog/2007/08/01/php-encryption-class/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация