You are here: Re: [PHP] How to declare Vars in PHP? « PHP « IT news, forums, messages
Re: [PHP] How to declare Vars in PHP?

Posted by Marek Kilimajer on 05/05/05 11:20

Jon M. wrote:
> I know it's not necessary, but I still want to know how.
>
>
> I know in JavaScript, that you declare vars like so:
>
> var = variableName;
>
> So I'm assuming that in PHP you do it like this:
>
> var = $variableName;

the above is wrong.

you can declare variable inside class definition using (php4):

var $varname [ = {default value} ];

but it's not necessery. It's good for documentation.

php5 gives you more control with public, protected and private keywords.

>
> But there doesn't seem to be a single shred of documentation on PHP.net (or
> in ANY book) that covers this. All they say is that it's good practice, but
> not necessary. Then they always skip telling you how.

outside of class definitions you declare a variable by assigning it a
value, for example:

$myvar = null;

That's it.

 

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

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