difference between var and private in a class

This is a discussion on difference between var and private in a class within the PHP Language forums, part of the PHP Programming Forums category; I've looked everywhere (including php.net) and can't seem to find the answer to this simple question. What'...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-23-2007
Bosconian
 
Posts: n/a
Default difference between var and private in a class

I've looked everywhere (including php.net) and can't seem to find the answer
to this simple question.

What's the difference between var and private when initializing a variable
in a class?

For example:

class myClass {

var $var1;
private $var2;

// constructor
function myClass() {
// do something
}

}


Reply With Quote
  #2 (permalink)  
Old 01-23-2007
Michael Fesser
 
Posts: n/a
Default Re: difference between var and private in a class

..oO(Bosconian)

>I've looked everywhere (including php.net) and can't seem to find the answer
>to this simple question.
>
>What's the difference between var and private when initializing a variable
>in a class?


'var' is deprecated and should be replaced with 'public'. From the
manual:

| Note: The PHP 4 method of declaring a variable with the var keyword is
| still supported for compatibility reasons (as a synonym for the public
| keyword). In PHP 5 before 5.1.3, its usage would generate an E_STRICT
| warning.

Visibility
http://www.php.net/manual/en/languag...visibility.php

Micha
Reply With Quote
  #3 (permalink)  
Old 01-23-2007
palle
 
Posts: n/a
Default Re: difference between var and private in a class

Bosconian wrote:
> I've looked everywhere (including php.net) and can't seem to find the answer
> to this simple question.
>
> What's the difference between var and private when initializing a variable
> in a class?
>
> For example:
>
> class myClass {
>
> var $var1;
> private $var2;
>



var is used in PHP4
it is still supported in PHP5, and is equal to public
Reply With Quote
  #4 (permalink)  
Old 01-23-2007
Bosconian
 
Posts: n/a
Default Re: difference between var and private in a class

"Michael Fesser" <netizen@gmx.de> wrote in message
news:kmsbr2tt7do79uaffb14t5t2g7s6r2so1s@4ax.com...
> .oO(Bosconian)
>
>>I've looked everywhere (including php.net) and can't seem to find the
>>answer
>>to this simple question.
>>
>>What's the difference between var and private when initializing a variable
>>in a class?

>
> 'var' is deprecated and should be replaced with 'public'. From the
> manual:
>
> | Note: The PHP 4 method of declaring a variable with the var keyword is
> | still supported for compatibility reasons (as a synonym for the public
> | keyword). In PHP 5 before 5.1.3, its usage would generate an E_STRICT
> | warning.
>
> Visibility
> http://www.php.net/manual/en/languag...visibility.php
>
> Micha


Ah-ha, very good. Thanks so much.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:25 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0