You are here: Re: variables type « PHP Programming Language « IT news, forums, messages
Re: variables type

Posted by Erwin Moller on 04/12/06 10:55

Tijs Verwest wrote:

> It's a newbie question...
>
> Is it possible to type variable in PHP inspite this is a loose type
> language. Or would that be required in some cases?

Hi,

PHP has the concept of types, however:

From manual:
-----------------
The type of a variable is usually not set by the programmer; rather, it is
decided at runtime by PHP depending on the context in which that variable
is used.
-----------------

Read more here:
http://nl2.php.net/manual/en/language.types.php

Also be sure to follow the link to 'Type Juggling'.

So, unlike strongtyped languages, in PHP you let the interpretation of the
type of a variable to the language itself.
In case of doubt you can ALWAYS cast to the type you want/demand.

for example:
$myInt = (int)$unclearValue;

You can also test for types, but that is all in the documentation.

In my experience, you do need the casting sometimes, but once you get
familiar with PHP it is easy to spot where.
If in doubt: just cast.

Good luck,
Erwin Moller

 

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

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