You are here: Re: declaring var of type « All PHP « IT news, forums, messages
Re: declaring var of type

Posted by Steve on 04/20/07 15:46

"Vince Morgan" <vinhar@REMOVEoptusnet.com.au> wrote in message
news:4628caca$0$11788$afc38c87@news.optusnet.com.au...
| I've just read that a var can be declared in php as follows:
| string $var1;
| integer $var2;

well, the above is both casting and declaring...

// cast

(string) $var1;

// declaring

string $var1;

| They aren't talking about casting.
| I've never seen this before and trying it in vers 5.0.3.3 shows that it
has
| no idea about it either.

there are more formal ways to cast in php. and you know me, i'm kind of
religious about code. :)

i use things like floatval(), intval(), bool()...and then settype().

now for all of this casting and typing, php itself does precious little even
when it knows you've typed the data explicitly. really, it helps you in
comparisons in statements/functions (i.e. if/then, function()). it also
helps you get correct output to the browser...as in using sprint_f, or,
ooooh, how about implicit casting using number_format (even though a string
is returned).

anyway, hth.

 

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

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