PHP var Keyword

PHP while Keyword
PHP use Keyword

In this article, you will learn abot var keyword in PHP. The var keyword in PHP creates a property in a class. Since PHP 5, it is equivalent to the public keyword.

examples of the VAR keyword

Example 1. In this example, we use var to create a property.

<?php
class MyClass {
  var $name = "John";
}

$obj = new MyClass();
echo $obj->name;
?>
PHP while Keyword
PHP use Keyword
en English
X
Scroll to Top