473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
}

}
Jan 23 '07 #1
3 2250
..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
Jan 23 '07 #2
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
Jan 23 '07 #3
"Michael Fesser" <ne*****@gmx.dewrote in message
news:km********************************@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.
Jan 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
3
by: DaveLessnau | last post by:
In a book on Data Structures that I'm reading, the authors are describing various linked lists and trees. In these, they start with some form of node class. What's driving me crazy is that they...
11
by: Opa | last post by:
Hi, I'm trying to get some private class members using reflection, but am having trouble: Example using System; using System.Reflection; public class Customer {
3
by: Klaus Löffelmann | last post by:
Hi, how is it possible to have a private class with public members? When doing some reasearch about double buffered paint actions, I stumbled on a class GraphicBufferManager which is declared...
3
by: Chu | last post by:
Hello All- I've got a Custom Web Control that with a public class that that sets a private variable inside the class. I plop the custom control onto my page and off I go. From my main page, I...
3
by: John Salerno | last post by:
I've been reading up on them, but I don't quite understand how they differ in practice. I know how each is implemented, and from C# I already know what a static method is. But I won't assume that...
10
by: Bonzol | last post by:
vb.net Hey there, could someone just tell me what the differnce is between classes and modules and when each one would be used compared to the other? Any help would be great Thanx in...
13
by: PromisedOyster | last post by:
Many in our development team have came from a C++ background and are in the practice of prefixing private class variables with an underscore to improve readability and avoid naming collisions with...
2
by: Edward Diener | last post by:
Specifying 'public class' or 'private class' for C++ class definitions is not part of the C++ standard. In a topic in the VS 2005 docs 'How to: Declare public and private on Native classes', it is...
19
by: AtulTiwari | last post by:
Can any one here who tell me that why we can not Declare a class or Interface as Private or Protected. I have just compiled a class as private class abc{ } then the compiler throw an error...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.