0

Hi

Why there is a var function when we create classes??

I tried to use a variable with out type var before it and it worked

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by diafol
0

The "var" prefix was used in PHP 4. In PHP 5, you don't need to use the word "var" to declare a variable. In PHP 5, however, a warning will be generated if error handling is set to E_STRICT.

0
In PHP 5, however, a warning will be generated if error handling is set to E_STRICT.

I think he answered your question before you asked it.

Declaring 'variable' properties with var in classes is good practice. Can't understand why you wouldn't want to.

Edited by diafol: n/a

0

Is VAR a function in PHP??
Is it used in a place other than the classes??

0

var is used to declare a variable property within a class.
I haven't seen them used for php anywhere else.
It's certainly NOT a function AFAIK.
var or similar (e.g. 'dim') is used to declare variables in many languages, but procedural php doesn't require this keyword.

Edited by diafol: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.